Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): fixing deprecated environment flag #3039

Merged
merged 2 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/cmd/resource_run_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func init() {
runCmd.Flags().StringSliceVar(&runParams.RequriedGates, "required-gates", []string{}, "override default required gate. "+validRequiredGatesMsg())

//deprecated
runCmd.Flags().StringVarP(&runParams.EnvID, "env", "e", "", "environment file or ID to be used")
runCmd.Flags().StringVarP(&runParams.EnvID, "environment", "e", "", "environment file or ID to be used")
runCmd.Flags().MarkDeprecated("env", "use --vars instead")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to change this line too? MarkDeprecated("environment"...

runCmd.Flags().MarkShorthandDeprecated("e", "use --vars instead")

Expand Down
36 changes: 35 additions & 1 deletion testing/cli-e2etest/testscenarios/test/run_test_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestRunTestWithHttpTriggerAndVariableSetFile(t *testing.T) {
environmentFile := env.GetTestResourcePath(t, "deprecated-environment")
testFile := env.GetTestResourcePath(t, "http-trigger-with-environment-file")

command := fmt.Sprintf("run test -f %s --env %s", testFile, environmentFile)
command := fmt.Sprintf("run test -f %s --environment %s", testFile, environmentFile)
result = tracetestcli.Exec(t, command, tracetestcli.WithCLIConfig(cliConfig))
helpers.RequireExitCodeEqual(t, result, 0)
require.Contains(result.StdOut, "✔ It should add a Pokemon correctly")
Expand Down Expand Up @@ -145,6 +145,40 @@ func TestRunTestWithHttpTriggerAndVariableSetFile(t *testing.T) {
require.Contains(result.StdOut, "✔ It should add a Pokemon correctly")
require.Contains(result.StdOut, "✔ It should save the correct data")
})

t.Run("should pass when using variable set id but using the old environment flag", func(t *testing.T) {
// Given I am a Tracetest CLI user
// And I have my server recently created
// And the datasource is already set

// When I create a variable set
// Then it should be created correctly
environmentFile := env.GetTestResourcePath(t, "variableSet-file")

result := tracetestcli.Exec(t, fmt.Sprintf("apply variableset --file %s", environmentFile), tracetestcli.WithCLIConfig(cliConfig))
helpers.RequireExitCodeEqual(t, result, 0)

environmentVars := helpers.UnmarshalYAML[types.VariableSetResource](t, result.StdOut)
require.Equal("VariableSet", environmentVars.Type)
require.Equal("pokeapi-env", environmentVars.Spec.ID)
require.Equal("pokeapi-env", environmentVars.Spec.Name)
require.Len(environmentVars.Spec.Values, 2)
require.Equal("POKEMON_NAME", environmentVars.Spec.Values[0].Key)
require.Equal("snorlax", environmentVars.Spec.Values[0].Value)
require.Equal("POKEMON_URL", environmentVars.Spec.Values[1].Key)
require.Equal("https://assets.pokemon.com/assets/cms2/img/pokedex/full/143.png", environmentVars.Spec.Values[1].Value)

// When I try to run a test with a http trigger and a variable set id
// Then it should pass

testFile := env.GetTestResourcePath(t, "http-trigger-with-environment-file")

command := fmt.Sprintf("run test -f %s --environment pokeapi-env", testFile)
result = tracetestcli.Exec(t, command, tracetestcli.WithCLIConfig(cliConfig))
helpers.RequireExitCodeEqual(t, result, 0)
require.Contains(result.StdOut, "✔ It should add a Pokemon correctly")
require.Contains(result.StdOut, "✔ It should save the correct data")
})
}

func TestRunTestWithGrpcTrigger(t *testing.T) {
Expand Down
Loading