Skip to content

Commit

Permalink
Increase test coverage for ChangeConfigEndpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Krithik Vaidya <[email protected]>
  • Loading branch information
krithikvaidya committed Sep 9, 2021
1 parent 4822993 commit d6a2052
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
16 changes: 12 additions & 4 deletions mesheryctl/pkg/utils/platform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

})
}
}
Expand All @@ -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)

Expand All @@ -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,
},
}
Expand Down Expand Up @@ -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")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions mesheryctl/pkg/utils/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit d6a2052

Please sign in to comment.