1
0
mirror of https://github.com/go-task/task.git synced 2024-12-04 10:24:45 +02:00

Write first test for deps

This commit is contained in:
Andrey Nering 2017-03-15 21:15:27 -03:00
parent 81f0e93bdb
commit 06633e2f99
4 changed files with 100 additions and 1 deletions

View File

@ -9,8 +9,8 @@ lint:
- golint .
- golint ./cmd/task
# TODO: have tests
test:
deps: [install]
cmds:
- go test -v

45
task_test.go Normal file
View File

@ -0,0 +1,45 @@
package task_test
import (
"os"
"os/exec"
"path/filepath"
"testing"
)
func TestDeps(t *testing.T) {
const dir = "testdata/deps"
files := []string{
"d1.txt",
"d2.txt",
"d3.txt",
"d11.txt",
"d12.txt",
"d13.txt",
"d21.txt",
"d22.txt",
"d23.txt",
"d31.txt",
"d32.txt",
"d33.txt",
}
for _, f := range files {
_ = os.Remove(f)
}
c := exec.Command("task")
c.Dir = dir
if err := c.Run(); err != nil {
t.Error(err)
return
}
for _, f := range files {
f = filepath.Join(dir, f)
if _, err := os.Stat(f); err != nil {
t.Errorf("File %s should exists", f)
}
}
}

1
testdata/deps/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.txt

53
testdata/deps/Taskfile.yml vendored Normal file
View File

@ -0,0 +1,53 @@
default:
deps: [d1, d2, d3]
d1:
deps: [d11, d12, d13]
cmds:
- echo 'Text' > d1.txt
d2:
deps: [d21, d22, d23]
cmds:
- echo 'Text' > d2.txt
d3:
deps: [d31, d32, d33]
cmds:
- echo 'Text' > d3.txt
d11:
cmds:
- echo 'Text' > d11.txt
d12:
cmds:
- echo 'Text' > d12.txt
d13:
cmds:
- echo 'Text' > d13.txt
d21:
cmds:
- echo 'Text' > d21.txt
d22:
cmds:
- echo 'Text' > d22.txt
d23:
cmds:
- echo 'Text' > d23.txt
d31:
cmds:
- echo 'Text' > d31.txt
d32:
cmds:
- echo 'Text' > d32.txt
d33:
cmds:
- echo 'Text' > d33.txt