1
0
mirror of https://github.com/go-task/task.git synced 2024-12-14 10:52:43 +02:00
task/cyclic_test.go

41 lines
729 B
Go
Raw Normal View History

package task_test
import (
"testing"
"github.com/go-task/task"
)
func TestCyclicDepCheck(t *testing.T) {
isCyclic := &task.Executor{
2017-06-04 21:41:38 +02:00
Tasks: task.Tasks{
"task-a": &task.Task{
2017-07-02 20:30:50 +02:00
Deps: []*task.Dep{&task.Dep{Task: "task-b"}},
},
"task-b": &task.Task{
2017-07-02 20:30:50 +02:00
Deps: []*task.Dep{&task.Dep{Task: "task-a"}},
},
},
}
if !isCyclic.HasCyclicDep() {
t.Error("Task should be cyclic")
}
isNotCyclic := &task.Executor{
2017-06-04 21:41:38 +02:00
Tasks: task.Tasks{
"task-a": &task.Task{
2017-07-02 20:30:50 +02:00
Deps: []*task.Dep{&task.Dep{Task: "task-c"}},
},
"task-b": &task.Task{
2017-07-02 20:30:50 +02:00
Deps: []*task.Dep{&task.Dep{Task: "task-c"}},
},
"task-c": &task.Task{},
},
}
if isNotCyclic.HasCyclicDep() {
t.Error("Task should not be cyclic")
}
}