diff options
Diffstat (limited to 'src/k8splugin/internal/app/instance_test.go')
-rw-r--r-- | src/k8splugin/internal/app/instance_test.go | 122 |
1 files changed, 0 insertions, 122 deletions
diff --git a/src/k8splugin/internal/app/instance_test.go b/src/k8splugin/internal/app/instance_test.go index 1b84b449..b79cf388 100644 --- a/src/k8splugin/internal/app/instance_test.go +++ b/src/k8splugin/internal/app/instance_test.go @@ -318,128 +318,6 @@ func TestInstanceGet(t *testing.T) { }) } -func TestInstanceStatus(t *testing.T) { - oldkrdPluginData := utils.LoadedPlugins - - defer func() { - utils.LoadedPlugins = oldkrdPluginData - }() - - err := LoadMockPlugins(utils.LoadedPlugins) - if err != nil { - t.Fatalf("LoadMockPlugins returned an error (%s)", err) - } - - t.Run("Successfully Get Instance Status", func(t *testing.T) { - db.DBconn = &db.MockDB{ - Items: map[string]map[string][]byte{ - InstanceKey{ID: "HaKpys8e"}.String(): { - "instanceStatus": []byte( - `{ - "request": { - "profile-name":"profile1", - "rb-name":"test-rbdef", - "rb-version":"v1", - "cloud-region":"region1" - }, - "ready": true, - "resourceCount": 2, - "podStatuses": [ - { - "name": "test-pod1", - "namespace": "default", - "ready": true, - "ipaddresses": ["192.168.1.1", "192.168.2.1"] - }, - { - "name": "test-pod2", - "namespace": "default", - "ready": true, - "ipaddresses": ["192.168.4.1", "192.168.5.1"] - } - ] - }`), - }, - }, - } - - expected := InstanceStatus{ - Request: InstanceRequest{ - RBName: "test-rbdef", - RBVersion: "v1", - ProfileName: "profile1", - CloudRegion: "region1", - }, - Ready: true, - ResourceCount: 2, - PodStatuses: []PodStatus{ - { - Name: "test-pod1", - Namespace: "default", - Ready: true, - IPAddresses: []string{"192.168.1.1", "192.168.2.1"}, - }, - { - Name: "test-pod2", - Namespace: "default", - Ready: true, - IPAddresses: []string{"192.168.4.1", "192.168.5.1"}, - }, - }, - } - ic := NewInstanceClient() - id := "HaKpys8e" - data, err := ic.Status(id) - if err != nil { - t.Fatalf("TestInstanceStatus returned an error (%s)", err) - } - if !reflect.DeepEqual(expected, data) { - t.Fatalf("TestInstanceStatus returned:\n result=%v\n expected=%v", - data, expected) - } - }) - - t.Run("Get non-existing Instance", func(t *testing.T) { - db.DBconn = &db.MockDB{ - Items: map[string]map[string][]byte{ - InstanceKey{ID: "HaKpys8e"}.String(): { - "instanceStatus": []byte( - `{ - "request": { - "profile-name":"profile1", - "rb-name":"test-rbdef", - "rb-version":"v1", - "cloud-region":"region1" - }, - "ready": true, - "resourceCount": 2, - "podStatuses": [ - { - "name": "test-pod1", - "namespace": "default", - "ready": true, - "ipaddresses": ["192.168.1.1", "192.168.2.1"] - }, - { - "name": "test-pod2", - "namespace": "default", - "ready": true, - "ipaddresses": ["192.168.4.1", "192.168.5.1"] - } - ] - }`), - }, - }, - } - - ic := NewInstanceClient() - _, err := ic.Get("non-existing") - if err == nil { - t.Fatal("Expected error, got pass", err) - } - }) -} - func TestInstanceFind(t *testing.T) { oldkrdPluginData := utils.LoadedPlugins |