Skip to content

test(cli): ensure first option selected with is expected #9770

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

Merged
merged 3 commits into from
Sep 19, 2023
Merged
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
Prev Previous commit
comments
  • Loading branch information
mtojek committed Sep 19, 2023
commit c41c8aff544f678932b82e47db31348c0faebec3
8 changes: 6 additions & 2 deletions cli/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ func TestUpdateValidateRichParameters(t *testing.T) {

// Update template
updatedTemplateParameters := []*proto.RichParameter{
// The order of rich parameter options must be maintained because `cliui.Select` automatically selects the first option during tests.
{Name: stringParameterName, Type: "string", Mutable: true, Required: true, Options: []*proto.RichParameterOption{
{Name: "first_option", Description: "This is first option", Value: "1"},
{Name: "second_option", Description: "This is second option", Value: "2"},
Expand All @@ -612,7 +613,7 @@ func TestUpdateValidateRichParameters(t *testing.T) {
}()

matches := []string{
// cliui.Select will pick "first_option".
// `cliui.Select` will automatically pick the first option
"Planning workspace...", "",
}
for i := 0; i < len(matches); i += 2 {
Expand Down Expand Up @@ -655,6 +656,7 @@ func TestUpdateValidateRichParameters(t *testing.T) {

// Update template - 2nd option disappeared, 4th option added
updatedTemplateParameters := []*proto.RichParameter{
// The order of rich parameter options must be maintained because `cliui.Select` automatically selects the first option during tests.
{Name: stringParameterName, Type: "string", Mutable: true, Required: true, Options: []*proto.RichParameterOption{
{Name: "Third option", Description: "This is third option", Value: "3rd"},
{Name: "First option", Description: "This is first option", Value: "1st"},
Expand All @@ -681,6 +683,7 @@ func TestUpdateValidateRichParameters(t *testing.T) {
}()

matches := []string{
// `cliui.Select` will automatically pick the first option
"Planning workspace...", "",
}
for i := 0; i < len(matches); i += 2 {
Expand Down Expand Up @@ -787,6 +790,7 @@ func TestUpdateValidateRichParameters(t *testing.T) {
// Update template: add required, immutable parameter
updatedTemplateParameters := []*proto.RichParameter{
templateParameters[0],
// The order of rich parameter options must be maintained because `cliui.Select` automatically selects the first option during tests.
{Name: immutableParameterName, Type: "string", Mutable: false, Required: true, Options: []*proto.RichParameterOption{
{Name: "thi", Description: "This is third option for immutable parameter", Value: "III"},
{Name: "fir", Description: "This is first option for immutable parameter", Value: "I"},
Expand All @@ -813,7 +817,7 @@ func TestUpdateValidateRichParameters(t *testing.T) {
}()

matches := []string{
// cliui.Select will pick "thi".
// `cliui.Select` will automatically pick the first option
"Planning workspace...", "",
}
for i := 0; i < len(matches); i += 2 {
Expand Down