mirror of
https://github.com/go-task/task.git
synced 2024-12-04 10:24:45 +02:00
test include variables
This commit is contained in:
parent
292cf75836
commit
2f18f7927d
29
task_test.go
29
task_test.go
@ -1218,3 +1218,32 @@ Bye!
|
||||
t.Log(buff.String())
|
||||
assert.Equal(t, strings.TrimSpace(buff.String()), expectedOutputOrder)
|
||||
}
|
||||
|
||||
func TestIncludedVars(t *testing.T) {
|
||||
const dir = "testdata/include_with_vars"
|
||||
var buff bytes.Buffer
|
||||
e := task.Executor{
|
||||
Dir: dir,
|
||||
Stdout: &buff,
|
||||
Stderr: &buff,
|
||||
}
|
||||
assert.NoError(t, e.Setup())
|
||||
|
||||
expectedOutputOrder := strings.TrimSpace(`
|
||||
task: [included1:task1] echo "VAR_1 is included1-var1"
|
||||
VAR_1 is included1-var1
|
||||
task: [included1:task1] echo "VAR_2 is incldued-default-var2"
|
||||
VAR_2 is incldued-default-var2
|
||||
task: [included2:task1] echo "VAR_1 is included2-var1"
|
||||
VAR_1 is included2-var1
|
||||
task: [included2:task1] echo "VAR_2 is incldued-default-var2"
|
||||
VAR_2 is incldued-default-var2
|
||||
task: [included3:task1] echo "VAR_1 is included-default-var1"
|
||||
VAR_1 is included-default-var1
|
||||
task: [included3:task1] echo "VAR_2 is incldued-default-var2"
|
||||
VAR_2 is incldued-default-var2
|
||||
`)
|
||||
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task1"}))
|
||||
t.Log(buff.String())
|
||||
assert.Equal(t, strings.TrimSpace(buff.String()), expectedOutputOrder)
|
||||
}
|
||||
|
20
testdata/include_with_vars/Taskfile.yml
vendored
Normal file
20
testdata/include_with_vars/Taskfile.yml
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
version: "3"
|
||||
|
||||
includes:
|
||||
included1:
|
||||
taskfile: include/Taskfile.include.yml
|
||||
vars:
|
||||
VAR_1: included1-var1
|
||||
included2:
|
||||
taskfile: include/Taskfile.include.yml
|
||||
vars:
|
||||
VAR_1: included2-var1
|
||||
included3:
|
||||
taskfile: include/Taskfile.include.yml
|
||||
|
||||
tasks:
|
||||
task1:
|
||||
cmds:
|
||||
- task: included1:task1
|
||||
- task: included2:task1
|
||||
- task: included3:task1
|
11
testdata/include_with_vars/include/Taskfile.include.yml
vendored
Normal file
11
testdata/include_with_vars/include/Taskfile.include.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
version: "3"
|
||||
|
||||
vars:
|
||||
VAR_1: included-default-var1
|
||||
VAR_2: incldued-default-var2
|
||||
|
||||
tasks:
|
||||
task1:
|
||||
cmds:
|
||||
- echo "VAR_1 is {{.VAR_1}}"
|
||||
- echo "VAR_2 is {{.VAR_2}}"
|
Loading…
Reference in New Issue
Block a user