diff --git a/mesheryctl/pkg/utils/fixtures/platform/TestChangeEndpointConfig.yaml b/mesheryctl/pkg/utils/fixtures/platform/TestChangeEndpointConfig.yaml new file mode 100644 index 00000000000..faeb81e3e56 --- /dev/null +++ b/mesheryctl/pkg/utils/fixtures/platform/TestChangeEndpointConfig.yaml @@ -0,0 +1,29 @@ +contexts: + gke: + adapters: + - meshery-istio + channel: stable + endpoint: http://localhost:9081 + platform: gke + token: Default + version: v0.4.2 + local: + endpoint: http://localhost:9081 + token: Default + platform: docker + adapters: + - meshery-istio + channel: stable + version: v0.5.10 + local2: + adapters: + - meshery-istio + channel: stable + version: v0.5.10 + endpoint: http://localhost:9081 + token: Default + platform: kubernetes +current-context: local +tokens: +- location: auth.json + name: Default diff --git a/mesheryctl/pkg/utils/fixtures/platform/original/TestChangeEndpointConfig.yaml b/mesheryctl/pkg/utils/fixtures/platform/original/TestChangeEndpointConfig.yaml new file mode 100644 index 00000000000..faeb81e3e56 --- /dev/null +++ b/mesheryctl/pkg/utils/fixtures/platform/original/TestChangeEndpointConfig.yaml @@ -0,0 +1,29 @@ +contexts: + gke: + adapters: + - meshery-istio + channel: stable + endpoint: http://localhost:9081 + platform: gke + token: Default + version: v0.4.2 + local: + endpoint: http://localhost:9081 + token: Default + platform: docker + adapters: + - meshery-istio + channel: stable + version: v0.5.10 + local2: + adapters: + - meshery-istio + channel: stable + version: v0.5.10 + endpoint: http://localhost:9081 + token: Default + platform: kubernetes +current-context: local +tokens: +- location: auth.json + name: Default diff --git a/mesheryctl/pkg/utils/platform_test.go b/mesheryctl/pkg/utils/platform_test.go index 57940363a73..8740f825475 100644 --- a/mesheryctl/pkg/utils/platform_test.go +++ b/mesheryctl/pkg/utils/platform_test.go @@ -122,6 +122,7 @@ func TestChangePlatform(t *testing.T) { if err := Populate(currDir+"/fixtures/platform/original/TestConfig.yaml", fixture); err != nil { t.Fatal(err, "Could not complete test. Unable to repopulate fixture") } + }) } } @@ -130,7 +131,7 @@ func TestChangeConfigEndpoint(t *testing.T) { // Setup path to test config file currDir := GetBasePath(t) - testConfigPath := currDir + "/fixtures/platform/TestConfig.yaml" + testConfigPath := currDir + "/fixtures/platform/TestChangeEndpointConfig.yaml" SetupCustomContextEnv(t, testConfigPath) @@ -144,10 +145,17 @@ func TestChangeConfigEndpoint(t *testing.T) { wantErr bool }{ { - name: "ChangeConfigEndpoint1", + name: "ChangeConfigEndpoint with platform docker", ctxName: "local", endpointAddress: "http://localhost:55555", - golden: "changeconfigendpoint.expect.golden", + golden: "changeconfigendpoint.expect.docker.golden", + wantErr: false, + }, + { + name: "ChangeConfigEndpoint with platform kubernetes", + ctxName: "local2", + endpointAddress: "http://localhost:44444", + golden: "changeconfigendpoint.expect.kubernetes.golden", wantErr: false, }, } @@ -193,7 +201,7 @@ func TestChangeConfigEndpoint(t *testing.T) { } // Repopulating Expected yaml - if err := Populate(currDir+"/fixtures/platform/original/TestConfig.yaml", testConfigPath); err != nil { + if err := Populate(currDir+"/fixtures/platform/original/TestChangeEndpointConfig.yaml", testConfigPath); err != nil { t.Fatal(err, "Could not complete test. Unable to repopulate fixture") } diff --git a/mesheryctl/pkg/utils/testdata/platform/changeconfigendpoint.expect.golden b/mesheryctl/pkg/utils/testdata/platform/changeconfigendpoint.expect.docker.golden similarity index 70% rename from mesheryctl/pkg/utils/testdata/platform/changeconfigendpoint.expect.golden rename to mesheryctl/pkg/utils/testdata/platform/changeconfigendpoint.expect.docker.golden index e9e6e1bdcfd..90efbb7546f 100644 --- a/mesheryctl/pkg/utils/testdata/platform/changeconfigendpoint.expect.golden +++ b/mesheryctl/pkg/utils/testdata/platform/changeconfigendpoint.expect.docker.golden @@ -15,6 +15,14 @@ contexts: - meshery-istio channel: stable version: v0.5.10 + local2: + adapters: + - meshery-istio + channel: stable + endpoint: http://localhost:9081 + platform: kubernetes + token: Default + version: v0.5.10 current-context: local tokens: - location: auth.json diff --git a/mesheryctl/pkg/utils/testdata/platform/changeconfigendpoint.expect.kubernetes.golden b/mesheryctl/pkg/utils/testdata/platform/changeconfigendpoint.expect.kubernetes.golden new file mode 100644 index 00000000000..d1419f79f50 --- /dev/null +++ b/mesheryctl/pkg/utils/testdata/platform/changeconfigendpoint.expect.kubernetes.golden @@ -0,0 +1,29 @@ +contexts: + gke: + adapters: + - meshery-istio + channel: stable + endpoint: http://localhost:9081 + platform: gke + token: Default + version: v0.4.2 + local: + adapters: + - meshery-istio + channel: stable + endpoint: http://localhost:9081 + platform: docker + token: Default + version: v0.5.10 + local2: + endpoint: http://localhost:44444 + token: Default + platform: kubernetes + adapters: + - meshery-istio + channel: stable + version: v0.5.10 +current-context: local +tokens: +- location: auth.json + name: Default diff --git a/mesheryctl/pkg/utils/testing.go b/mesheryctl/pkg/utils/testing.go index cc73799c920..a847f99bfa4 100644 --- a/mesheryctl/pkg/utils/testing.go +++ b/mesheryctl/pkg/utils/testing.go @@ -167,6 +167,10 @@ func SetupLogrusGrabTesting(t *testing.T) *bytes.Buffer { // setup custom context with SetupCustomContextEnv func SetupCustomContextEnv(t *testing.T, pathToContext string) { viper.Reset() + ViperCompose = viper.New() + ViperDocker = viper.New() + ViperK8s = viper.New() + viper.SetConfigFile(pathToContext) DefaultConfigPath = pathToContext //fmt.Println(viper.ConfigFileUsed())