-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update(cli-e2e): Add e2e tests for the environment resource (#2680)
* Update environment tests * Adding more tests to environment * Updating tests * Updating tests * Updating tests and documentation * Updating list tests * Adding more test cases * Updating test timeout to 5 min * Updating environment list pretty test * Adding more tests
- Loading branch information
1 parent
e862b9d
commit 71ec435
Showing
17 changed files
with
650 additions
and
129 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
55 changes: 55 additions & 0 deletions
55
testing/cli-e2etest/testscenarios/environment/delete_environment_test.go
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,55 @@ | ||
package environment | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/kubeshop/tracetest/cli-e2etest/environment" | ||
"github.com/kubeshop/tracetest/cli-e2etest/helpers" | ||
"github.com/kubeshop/tracetest/cli-e2etest/testscenarios/types" | ||
"github.com/kubeshop/tracetest/cli-e2etest/tracetestcli" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestDeleteEnvironment(t *testing.T) { | ||
// instantiate require with testing helper | ||
require := require.New(t) | ||
|
||
// setup isolated e2e environment | ||
env := environment.CreateAndStart(t) | ||
defer env.Close(t) | ||
|
||
cliConfig := env.GetCLIConfigPath(t) | ||
|
||
// Given I am a Tracetest CLI user | ||
// And I have my server recently created | ||
|
||
// When I try to delete an environment that don't exo | ||
// Then it should return an error and say that this resource does not exist | ||
result := tracetestcli.Exec(t, "delete environment --id .env", tracetestcli.WithCLIConfig(cliConfig)) | ||
helpers.RequireExitCodeEqual(t, result, 1) | ||
require.Contains(result.StdErr, "Resource environments with ID .env not found") // TODO: update this message to singular | ||
|
||
// When I try to set up a new environment | ||
// Then it should be applied with success | ||
newEnvironmentPath := env.GetTestResourcePath(t, "new-environment") | ||
|
||
result = tracetestcli.Exec(t, fmt.Sprintf("apply environment --file %s", newEnvironmentPath), tracetestcli.WithCLIConfig(cliConfig)) | ||
helpers.RequireExitCodeEqual(t, result, 0) | ||
|
||
environmentVars := helpers.UnmarshalYAML[types.EnvironmentResource](t, result.StdOut) | ||
require.Equal("Environment", environmentVars.Type) | ||
require.Equal(".env", environmentVars.Spec.ID) | ||
|
||
// When I try to delete the environment | ||
// Then it should delete with success | ||
result = tracetestcli.Exec(t, "delete environment --id .env", tracetestcli.WithCLIConfig(cliConfig)) | ||
helpers.RequireExitCodeEqual(t, result, 0) | ||
require.Contains(result.StdOut, "✔ Environment successfully deleted") | ||
|
||
// When I try to get an environment again | ||
// Then it should return a message saying that the environment was not found | ||
result = tracetestcli.Exec(t, "get environment --id .env --output yaml", tracetestcli.WithCLIConfig(cliConfig)) | ||
helpers.RequireExitCodeEqual(t, result, 0) | ||
require.Contains(result.StdOut, "Resource environment with ID .env not found") | ||
} |
Oops, something went wrong.