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
11 changes: 11 additions & 0 deletions src/test/e2e/runner_inputs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,15 @@ func TestRunnerInputs(t *testing.T) {
require.NoError(t, err, stdOut, stdErr)
require.Contains(t, stdErr, "Input1Tmpl: input1 Input1Env: input1 Input2Tmpl: input2 Input2Env: input2 Input3Tmpl: notthedefault Input3Env: notthedefault Var: baz")
})

t.Run("test that invalid inputs are rejected", func(t *testing.T) {
stdOut, stdErr, err := e2e.Maru("run", "with:input-with-regex", "--file", "src/test/tasks/inputs/tasks.yaml", "--with", "not-empty-and-number=notanumber")
Comment thread
RothAndrew marked this conversation as resolved.
require.Error(t, err, stdOut, stdErr)
})

t.Run("test that inputs that match regex are accepted", func(t *testing.T) {
stdOut, stdErr, err := e2e.Maru("run", "with:input-with-regex", "--file", "src/test/tasks/inputs/tasks.yaml", "--with", "not-empty=hello!", "--with", "not-empty-and-number=12345")
Comment thread
RothAndrew marked this conversation as resolved.
require.NoError(t, err, stdOut, stdErr)
require.Contains(t, stdErr, "hello! 12345")
})
}
16 changes: 16 additions & 0 deletions src/test/tasks/inputs/tasks-with-inputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,19 @@ tasks:
actions:
- cmd: |
echo "Input1Tmpl: ${{ .inputs.input1 }} Input1Env: $INPUT_INPUT1 Input2Tmpl: ${{ .inputs.input2 }} Input2Env: ${INPUT_INPUT2} Input3Tmpl: ${{ .inputs.input3 }} Input3Env: $INPUT_INPUT3 Var: $FOO"

- name: input-with-regex
description: Test task that uses regex to validate inputs
inputs:
not-empty:
description: An input that should not be empty
required: true
default: ${SOME_NONEXISTENT_ENV_VAR}
pattern: ".+"
not-empty-and-number:
description: An input that should be a number
required: true
pattern: "[0-9]+"
actions:
- cmd: |
echo ${{ index .inputs "not-empty" }} ${{ index .inputs "not-empty-and-number" }}