1
0
mirror of https://github.com/go-task/task.git synced 2025-11-25 22:32:55 +02:00

fix: interpolate includes taskfile and dir

This commit is contained in:
Pete Davison
2022-11-23 17:58:08 +00:00
parent d55282b53c
commit f1d516cf2a
4 changed files with 51 additions and 1 deletions

View File

@@ -1059,6 +1059,40 @@ func TestIncludesInternal(t *testing.T) {
}
}
func TestIncludesInterpolation(t *testing.T) {
const dir = "testdata/includes_interpolation"
tests := []struct {
name string
task string
expectedErr bool
expectedOutput string
}{
{"include", "include", false, "includes_interpolation\n"},
{"include with dir", "include-with-dir", false, "included\n"},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
var buff bytes.Buffer
e := task.Executor{
Dir: dir,
Stdout: &buff,
Stderr: &buff,
Silent: true,
}
assert.NoError(t, e.Setup())
err := e.Run(context.Background(), taskfile.Call{Task: test.task})
if test.expectedErr {
assert.Error(t, err)
} else {
assert.NoError(t, err)
}
assert.Equal(t, test.expectedOutput, buff.String())
})
}
}
func TestInternalTask(t *testing.T) {
const dir = "testdata/internal_task"
tests := []struct {