mirror of
https://github.com/go-task/task.git
synced 2025-06-13 00:07:29 +02:00
Task directory: test default case (no "dir:" attribute)
This commit is contained in:
parent
74537689dc
commit
81baf808c9
19
task_test.go
19
task_test.go
@ -575,3 +575,22 @@ func readTestFixture(t *testing.T, dir string, file string) string {
|
||||
assert.NoError(t, err, "error reading text fixture")
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func TestWhenNoDirAttributeItRunsInSameDirAsTaskfile(t *testing.T) {
|
||||
const expected = "dir"
|
||||
const dir = "testdata/" + expected
|
||||
var out bytes.Buffer
|
||||
e := &task.Executor{
|
||||
Dir: dir,
|
||||
Stdout: &out,
|
||||
Stderr: &out,
|
||||
}
|
||||
|
||||
assert.NoError(t, e.Setup())
|
||||
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "whereami"}))
|
||||
|
||||
// got should be the "dir" part of "testdata/dir"
|
||||
got := strings.TrimSuffix(filepath.Base(out.String()), "\n")
|
||||
assert.Equal(t, expected, got, "Mismatch in the working directory")
|
||||
}
|
||||
|
||||
|
7
testdata/dir/Taskfile.yml
vendored
Normal file
7
testdata/dir/Taskfile.yml
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
version: '2'
|
||||
|
||||
tasks:
|
||||
whereami:
|
||||
cmds:
|
||||
- pwd
|
||||
silent: true
|
Loading…
x
Reference in New Issue
Block a user