1
0
mirror of https://github.com/go-task/task.git synced 2025-06-15 00:15:10 +02:00

Add status option to prevent task from running

Closes #27
This commit is contained in:
Andrey Nering
2017-05-17 14:37:11 -03:00
parent 86e0496555
commit 2a2dfce137
4 changed files with 58 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package task_test
import (
"bytes"
"io/ioutil"
"os"
"os/exec"
@ -112,3 +113,34 @@ func TestTaskCall(t *testing.T) {
}
}
}
func TestStatus(t *testing.T) {
const dir = "testdata/status"
var file = filepath.Join(dir, "foo.txt")
_ = os.Remove(file)
if _, err := os.Stat(file); err == nil {
t.Errorf("File should not exists: %v", err)
}
c := exec.Command("task", "gen-foo")
c.Dir = dir
if err := c.Run(); err != nil {
t.Error(err)
}
if _, err := os.Stat(file); err != nil {
t.Errorf("File should exists: %v", err)
}
buff := bytes.NewBuffer(nil)
c = exec.Command("task", "gen-foo")
c.Dir = dir
c.Stderr = buff
c.Stdout = buff
if err := c.Run(); err != nil {
t.Error(err)
}
if buff.String() != `task: Task "gen-foo" is up to date`+"\n" {
t.Errorf("Wrong output message: %s", buff.String())
}
}