summaryrefslogtreecommitdiffstats
path: root/src/k8splugin/internal/app/client_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/client_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/client_test.go')
-rw-r--r--src/k8splugin/internal/app/client_test.go26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/k8splugin/internal/app/client_test.go b/src/k8splugin/internal/app/client_test.go
index 4cc533e2..4bfbcb18 100644
--- a/src/k8splugin/internal/app/client_test.go
+++ b/src/k8splugin/internal/app/client_test.go
@@ -14,12 +14,16 @@ limitations under the License.
package app
import (
+ "encoding/base64"
+ "io/ioutil"
"os"
"plugin"
"reflect"
"testing"
utils "k8splugin/internal"
+ "k8splugin/internal/connection"
+ "k8splugin/internal/db"
"k8splugin/internal/helm"
pkgerrors "github.com/pkg/errors"
@@ -46,9 +50,29 @@ func LoadMockPlugins(krdLoadedPlugins map[string]*plugin.Plugin) error {
func TestInit(t *testing.T) {
t.Run("Successfully create Kube Client", func(t *testing.T) {
+ // 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")
+ }
+
+ fdbase64 := base64.StdEncoding.EncodeToString(fd)
+
+ // Create mock db with connectivity information in it
+ db.DBconn = &db.MockDB{
+ Items: map[string]map[string][]byte{
+ connection.ConnectionKey{CloudRegion: "mock_connection"}.String(): {
+ "metadata": []byte(
+ "{\"cloud-region\":\"mock_connection\"," +
+ "\"cloud-owner\":\"mock_owner\"," +
+ "\"kubeconfig\": \"" + fdbase64 + "\"}"),
+ },
+ },
+ }
kubeClient := KubernetesClient{}
- err := kubeClient.init("../../mock_files/mock_configs/mock_kube_config")
+ // Refer to the connection via its name
+ err = kubeClient.init("mock_connection")
if err != nil {
t.Fatalf("TestGetKubeClient returned an error (%s)", err)
}