
Brought over the .golangci.yaml file from airshipctl Made necessiary corrections based on it The goimports section in .golangi.yaml will need to be addressed, not currently working for airshipui Change-Id: I43973224703408a3320e43a59b4639d6d3edd1ca
59 lines
1.1 KiB
Go
Executable File
59 lines
1.1 KiB
Go
Executable File
/*
|
|
Copyright (c) 2020 AT&T. All Rights Reserved.
|
|
SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
package plugin
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/vmware-tanzu/octant/pkg/plugin/service"
|
|
)
|
|
|
|
func TestRegister(t *testing.T) {
|
|
plugin, err := Register("openstack", "OpenStack test version")
|
|
if err != nil {
|
|
t.Fatalf("Registering the plugin returned an error")
|
|
}
|
|
|
|
err = plugin.Validate()
|
|
if err != nil {
|
|
t.Fatalf("Validating the plugin returned an error")
|
|
}
|
|
}
|
|
|
|
func TestRoutes(t *testing.T) {
|
|
router := service.NewRouter()
|
|
NewOpenstackPlugin().initRoutes(router)
|
|
|
|
tests := []struct {
|
|
path string
|
|
exists bool
|
|
}{
|
|
{
|
|
path: "",
|
|
exists: true,
|
|
},
|
|
{
|
|
path: "/not-real",
|
|
exists: false,
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
test := test // pin the value so that the following function literal binds to it
|
|
t.Run(fmt.Sprintf("Path='%s'", test.path), func(t *testing.T) {
|
|
_, found := router.Match(test.path)
|
|
|
|
if test.exists != found {
|
|
if found {
|
|
t.Errorf("Found path '%s' when it should not exist.", test.path)
|
|
} else {
|
|
t.Errorf("Didn't find path '%s' when it should exist.", test.path)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|