Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions cmd/cycloid/environments/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func create(cmd *cobra.Command, args []string) error {
color = *current.Color
} else {
// Use a random one if none is set
color = cyargs.PickRandomColor(&env)
color = cyargs.PickRandomColor(nil)
}
}

Expand All @@ -109,7 +109,7 @@ func create(cmd *cobra.Command, args []string) error {
}

if color == cyargs.DefaultColor {
color = cyargs.PickRandomColor(&env)
color = cyargs.PickRandomColor(nil)
}

resp, _, err := m.CreateEnv(org, project, env, name, color)
Expand Down
37 changes: 37 additions & 0 deletions e2e/environments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,43 @@ func TestEnvs(t *testing.T) {
})
})

t.Run("CreateWithoutColorRandomized", func(t *testing.T) {
newEnv := randomCanonical("e2e-env-no-color")
args := []string{
"-o", "json",
"env", "create",
"--project", project,
"--env", newEnv,
"--name", "No color env",
}
out, err := executeCommand(args)
if err != nil {
t.Errorf("failed to create env '%s' without color: %v", newEnv, err)
}

defer t.Run("DeleteNoColorEnv", func(t *testing.T) {
args := []string{
"env", "delete",
"--project", project,
"--env", newEnv,
}
_, err := executeCommand(args)
if err != nil {
t.Errorf("failed to delete env '%s': %v", newEnv, err)
}
})

var envResult models.Environment
err = json.Unmarshal([]byte(out), &envResult)
if err != nil {
t.Errorf("failed to parse json output from the CLI on create without color: %v\noutput: %s", err, out)
}

if assert.NotNil(t, envResult.Color, "expected a random color to be assigned") {
assert.Contains(t, cyargs.ValidColors, *envResult.Color)
}
})

t.Run("Update", func(t *testing.T) {
var newName = "NewName"
args := []string{
Expand Down