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

fix: pattern not properly being checked #145

Merged
merged 2 commits into from
Sep 20, 2024
Merged
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
1 change: 1 addition & 0 deletions src/pkg/variables/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func (vc *VariableConfig[T]) PopulateVariables(variables []InteractiveVariable[T

// Variable is present, no need to continue checking
if present {
vc.setVariableMap[variable.Name].Pattern = variable.Pattern
vc.setVariableMap[variable.Name].Extra = variable.Extra
if err := vc.CheckVariablePattern(variable.Name); err != nil {
return err
Expand Down
16 changes: 16 additions & 0 deletions src/test/e2e/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,20 @@ func TestTaskRunner(t *testing.T) {
require.NoError(t, err, stdOut, stdErr)
require.Contains(t, stdErr, "\"input val2 equals 5 and variable VAL1 equals 5\"")
})

t.Run("run successful pattern", func(t *testing.T) {
t.Parallel()

stdOut, stdErr, err := e2e.Maru("run", "--file", "src/test/tasks/more-tasks/pattern.yaml", "--set", "HELLO=HELLO")
require.NoError(t, err, stdOut, stdErr)
require.Contains(t, stdErr, "HELLO")
})

t.Run("run unsuccessful pattern", func(t *testing.T) {
t.Parallel()

stdOut, stdErr, err := e2e.Maru("run", "--file", "src/test/tasks/more-tasks/pattern.yaml", "--set", "HELLO=HI")
require.Error(t, err, stdOut, stdErr)
require.Contains(t, stdErr, "\"HELLO\" does not match pattern \"^HELLO$\"")
})
}
8 changes: 8 additions & 0 deletions src/test/tasks/more-tasks/pattern.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
variables:
- name: HELLO
pattern: ^HELLO$

tasks:
- name: default
actions:
- cmd: echo ${HELLO}
Loading