1
0
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:
Josh Bebbington
2018-07-31 23:09:55 +01:00
parent 3f7e8c88eb
commit 00a0755ff3
2 changed files with 25 additions and 0 deletions

View File

@ -432,3 +432,25 @@ func TestExpand(t *testing.T) {
assert.NoError(t, e.Run(taskfile.Call{Task: "pwd"})) assert.NoError(t, e.Run(taskfile.Call{Task: "pwd"}))
assert.Equal(t, home, strings.TrimSpace(buff.String())) 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
View File

@ -0,0 +1,3 @@
build:
cmds:
- touch file.txt