mirror of https://github.com/databricks/cli.git
Fixed --environment flag (#705)
## Changes Fixed --environment flag Fixes https://github.com/databricks/setup-cli/issues/35 ## Tests Added regression test
This commit is contained in:
parent
5f6289e3a7
commit
5477afe4f4
|
@ -26,7 +26,7 @@ func getTarget(cmd *cobra.Command) (value string) {
|
||||||
|
|
||||||
oldFlag := cmd.Flag("environment")
|
oldFlag := cmd.Flag("environment")
|
||||||
if oldFlag != nil {
|
if oldFlag != nil {
|
||||||
value = flag.Value.String()
|
value = oldFlag.Value.String()
|
||||||
if value != "" {
|
if value != "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ func TestTargetFlagFull(t *testing.T) {
|
||||||
err := cmd.ExecuteContext(ctx)
|
err := cmd.ExecuteContext(ctx)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, cmd.Flag("target").Value.String(), "development")
|
assert.Equal(t, getTarget(cmd), "development")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTargetFlagShort(t *testing.T) {
|
func TestTargetFlagShort(t *testing.T) {
|
||||||
|
@ -150,5 +150,19 @@ func TestTargetFlagShort(t *testing.T) {
|
||||||
err := cmd.ExecuteContext(ctx)
|
err := cmd.ExecuteContext(ctx)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, cmd.Flag("target").Value.String(), "production")
|
assert.Equal(t, getTarget(cmd), "production")
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove when environment flag is fully deprecated
|
||||||
|
func TestTargetEnvironmentFlag(t *testing.T) {
|
||||||
|
cmd := emptyCommand(t)
|
||||||
|
initTargetFlag(cmd)
|
||||||
|
initEnvironmentFlag(cmd)
|
||||||
|
cmd.SetArgs([]string{"version", "--environment", "development"})
|
||||||
|
|
||||||
|
ctx := context.Background()
|
||||||
|
err := cmd.ExecuteContext(ctx)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
assert.Equal(t, getTarget(cmd), "development")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue