2017-03-25 21:06:49 +02:00
|
|
|
package task_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/go-task/task"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCyclicDepCheck(t *testing.T) {
|
2017-06-04 21:02:04 +02:00
|
|
|
isCyclic := &task.Executor{
|
|
|
|
Tasks: map[string]*task.Task{
|
|
|
|
"task-a": &task.Task{
|
|
|
|
Deps: []string{"task-b"},
|
|
|
|
},
|
|
|
|
"task-b": &task.Task{
|
|
|
|
Deps: []string{"task-a"},
|
|
|
|
},
|
2017-03-25 21:06:49 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-06-04 21:02:04 +02:00
|
|
|
if !isCyclic.HasCyclicDep() {
|
2017-03-25 21:06:49 +02:00
|
|
|
t.Error("Task should be cyclic")
|
|
|
|
}
|
|
|
|
|
2017-06-04 21:02:04 +02:00
|
|
|
isNotCyclic := &task.Executor{
|
|
|
|
Tasks: map[string]*task.Task{
|
|
|
|
"task-a": &task.Task{
|
|
|
|
Deps: []string{"task-c"},
|
|
|
|
},
|
|
|
|
"task-b": &task.Task{
|
|
|
|
Deps: []string{"task-c"},
|
|
|
|
},
|
|
|
|
"task-c": &task.Task{},
|
2017-03-25 21:06:49 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-06-04 21:02:04 +02:00
|
|
|
if isNotCyclic.HasCyclicDep() {
|
2017-03-25 21:06:49 +02:00
|
|
|
t.Error("Task should not be cyclic")
|
|
|
|
}
|
|
|
|
}
|