-
Notifications
You must be signed in to change notification settings - Fork 785
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #2196 - the `omitempty` json tag was missing from the ExposeControllerConfig struct, which resulted in empty values being present in the extraValues.yaml file - thus overriding valid values from the values.yaml file - the cmdline flags passed through `jx preview` for the ExposeControllerConfig struct were not used to generate the extraValues.yaml file also extracting the preview values config in a func, to unit test it
- Loading branch information
Showing
3 changed files
with
123 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package cmd_test | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/jenkins-x/jx/pkg/config" | ||
"github.com/jenkins-x/jx/pkg/jx/cmd" | ||
) | ||
|
||
func TestGetPreviewValuesConfig(t *testing.T) { | ||
tests := []struct { | ||
opts cmd.PreviewOptions | ||
env map[string]string | ||
domain string | ||
expectedYAMLConfig string | ||
}{ | ||
{ | ||
opts: cmd.PreviewOptions{ | ||
HelmValuesConfig: config.HelmValuesConfig{ | ||
ExposeController: &config.ExposeController{}, | ||
}, | ||
}, | ||
env: map[string]string{ | ||
cmd.DOCKER_REGISTRY: "my.registry", | ||
cmd.ORG: "my-org", | ||
cmd.APP_NAME: "my-app", | ||
cmd.PREVIEW_VERSION: "1.0.0", | ||
}, | ||
expectedYAMLConfig: `expose: {} | ||
preview: | ||
image: | ||
repository: my.registry/my-org/my-app | ||
tag: 1.0.0 | ||
`, | ||
}, | ||
{ | ||
opts: cmd.PreviewOptions{ | ||
HelmValuesConfig: config.HelmValuesConfig{ | ||
ExposeController: &config.ExposeController{ | ||
Config: config.ExposeControllerConfig{ | ||
HTTP: "false", | ||
TLSAcme: "true", | ||
}, | ||
}, | ||
}, | ||
}, | ||
env: map[string]string{ | ||
cmd.DOCKER_REGISTRY: "my.registry", | ||
cmd.ORG: "my-org", | ||
cmd.APP_NAME: "my-app", | ||
cmd.PREVIEW_VERSION: "1.0.0", | ||
}, | ||
domain: "jenkinsx.io", | ||
expectedYAMLConfig: `expose: | ||
config: | ||
domain: jenkinsx.io | ||
http: "false" | ||
tlsacme: "true" | ||
preview: | ||
image: | ||
repository: my.registry/my-org/my-app | ||
tag: 1.0.0 | ||
`, | ||
}, | ||
} | ||
|
||
for i, test := range tests { | ||
for k, v := range test.env { | ||
os.Setenv(k, v) | ||
} | ||
|
||
config, err := test.opts.GetPreviewValuesConfig(test.domain) | ||
if err != nil { | ||
t.Errorf("[%d] got unexpected err: %v", i, err) | ||
continue | ||
} | ||
|
||
configYAML, err := config.String() | ||
if err != nil { | ||
t.Errorf("[%d] %v", i, err) | ||
continue | ||
} | ||
|
||
if test.expectedYAMLConfig != configYAML { | ||
t.Errorf("[%d] expected %#v but got %#v", i, test.expectedYAMLConfig, configYAML) | ||
} | ||
} | ||
} |