mirror of
https://github.com/go-task/task.git
synced 2025-04-17 12:06:30 +02:00
Write first test for deps
This commit is contained in:
parent
81f0e93bdb
commit
06633e2f99
@ -9,8 +9,8 @@ lint:
|
|||||||
- golint .
|
- golint .
|
||||||
- golint ./cmd/task
|
- golint ./cmd/task
|
||||||
|
|
||||||
# TODO: have tests
|
|
||||||
test:
|
test:
|
||||||
|
deps: [install]
|
||||||
cmds:
|
cmds:
|
||||||
- go test -v
|
- go test -v
|
||||||
|
|
||||||
|
45
task_test.go
Normal file
45
task_test.go
Normal 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
1
testdata/deps/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.txt
|
53
testdata/deps/Taskfile.yml
vendored
Normal file
53
testdata/deps/Taskfile.yml
vendored
Normal 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
|
Loading…
x
Reference in New Issue
Block a user