summaryrefslogtreecommitdiffstats
path: root/src/k8splugin/internal/app/instance_test.go
diff options
context:
space:
mode:
authorKiran Kamineni <kiran.k.kamineni@intel.com>2019-05-01 12:31:14 -0700
committerKiran Kamineni <kiran.k.kamineni@intel.com>2019-05-02 15:25:21 -0700
commita2ae972e814f80184033ee75e9715d1d76323410 (patch)
tree0916ce2ef051b455a76756ba8bd4d9c6d8efd72e /src/k8splugin/internal/app/instance_test.go
parent2eec43edc8b9a438865422fcf6ae340c2aec036d (diff)
Create kubeconfig files in kubeconfig dir
The connectivity api should allow the creation of kubeconfig files in the kubeconfig dir. Issue-ID: MULTICLOUD-292 Change-Id: I5ecc92622648c6c90b71ffad433a132e191cf4b3 Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
Diffstat (limited to 'src/k8splugin/internal/app/instance_test.go')
-rw-r--r--src/k8splugin/internal/app/instance_test.go33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/k8splugin/internal/app/instance_test.go b/src/k8splugin/internal/app/instance_test.go
index ab39dfb7..6ab14a34 100644
--- a/src/k8splugin/internal/app/instance_test.go
+++ b/src/k8splugin/internal/app/instance_test.go
@@ -14,12 +14,14 @@ limitations under the License.
package app
import (
+ "encoding/base64"
+ "io/ioutil"
"log"
"reflect"
"testing"
utils "k8splugin/internal"
- "k8splugin/internal/config"
+ "k8splugin/internal/connection"
"k8splugin/internal/db"
"k8splugin/internal/helm"
"k8splugin/internal/rb"
@@ -37,6 +39,12 @@ func TestInstanceCreate(t *testing.T) {
t.Fatalf("LoadMockPlugins returned an error (%s)", err)
}
+ // Load the mock kube config file into memory
+ fd, err := ioutil.ReadFile("../../mock_files/mock_configs/mock_kube_config")
+ if err != nil {
+ t.Fatal("Unable to read mock_kube_config")
+ }
+
t.Run("Successfully create Instance", func(t *testing.T) {
db.DBconn = &db.MockDB{
Items: map[string]map[string][]byte{
@@ -145,6 +153,12 @@ func TestInstanceCreate(t *testing.T) {
"RZQl9kOgrk+XoOzX68tJ3wYJb0N/RJ0NzPUr5y4YEDBw4cOHDgwIEDBw4cOHDgwIEDBw4" +
"cOHDgwIEDB18K/AcxEDJDAHgAAA=="),
},
+ connection.ConnectionKey{CloudRegion: "mock_connection"}.String(): {
+ "metadata": []byte(
+ "{\"cloud-region\":\"mock_connection\"," +
+ "\"cloud-owner\":\"mock_owner\"," +
+ "\"kubeconfig\": \"" + base64.StdEncoding.EncodeToString(fd) + "\"}"),
+ },
},
}
@@ -153,10 +167,9 @@ func TestInstanceCreate(t *testing.T) {
RBName: "test-rbdef",
RBVersion: "v1",
ProfileName: "profile1",
- CloudRegion: "mock_kube_config",
+ CloudRegion: "mock_connection",
}
- config.SetConfigValue("KubeConfigDir", "../../mock_files/mock_configs")
ir, err := ic.Create(input)
if err != nil {
t.Fatalf("TestInstanceCreate returned an error (%s)", err)
@@ -311,6 +324,12 @@ func TestInstanceDelete(t *testing.T) {
t.Fatalf("TestInstanceDelete returned an error (%s)", err)
}
+ // Load the mock kube config file into memory
+ fd, err := ioutil.ReadFile("../../mock_files/mock_configs/mock_kube_config")
+ if err != nil {
+ t.Fatal("Unable to read mock_kube_config")
+ }
+
t.Run("Successfully delete Instance", func(t *testing.T) {
db.DBconn = &db.MockDB{
Items: map[string]map[string][]byte{
@@ -322,7 +341,7 @@ func TestInstanceDelete(t *testing.T) {
"namespace":"testnamespace",
"rb-name":"test-rbdef",
"rb-version":"v1",
- "cloud-region":"mock_kube_config",
+ "cloud-region":"mock_connection",
"resources": [
{
"GVK": {
@@ -343,6 +362,12 @@ func TestInstanceDelete(t *testing.T) {
]
}`),
},
+ connection.ConnectionKey{CloudRegion: "mock_connection"}.String(): {
+ "metadata": []byte(
+ "{\"cloud-region\":\"mock_connection\"," +
+ "\"cloud-owner\":\"mock_owner\"," +
+ "\"kubeconfig\": \"" + base64.StdEncoding.EncodeToString(fd) + "\"}"),
+ },
},
}