mirror of
https://github.com/go-task/task.git
synced 2025-07-03 00:57:02 +02:00
Added test for executor.DryRun
This commit is contained in:
22
task_test.go
22
task_test.go
@ -432,3 +432,25 @@ func TestExpand(t *testing.T) {
|
||||
assert.NoError(t, e.Run(taskfile.Call{Task: "pwd"}))
|
||||
assert.Equal(t, home, strings.TrimSpace(buff.String()))
|
||||
}
|
||||
|
||||
func TestDryRun(t *testing.T) {
|
||||
const dir = "testdata/dryrun"
|
||||
|
||||
file := filepath.Join(dir, "file.txt")
|
||||
_ = os.Remove(file)
|
||||
|
||||
var buff bytes.Buffer
|
||||
|
||||
e := task.Executor{
|
||||
Dir: dir,
|
||||
Stdout: &buff,
|
||||
Stderr: &buff,
|
||||
DryRun: true,
|
||||
}
|
||||
assert.NoError(t, e.Setup())
|
||||
assert.NoError(t, e.Run(taskfile.Call{Task: "build"}))
|
||||
|
||||
if _, err := os.Stat(file); err == nil {
|
||||
t.Errorf("File should not exist %s", file)
|
||||
}
|
||||
}
|
||||
|
3
testdata/dryrun/Taskfile.yml
vendored
Normal file
3
testdata/dryrun/Taskfile.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
build:
|
||||
cmds:
|
||||
- touch file.txt
|
Reference in New Issue
Block a user