1
0
mirror of https://github.com/go-task/task.git synced 2025-01-04 03:48:02 +02:00
task/cyclic_test.go

41 lines
671 B
Go
Raw Normal View History

package task_test
import (
"testing"
"github.com/go-task/task"
)
func TestCyclicDepCheck(t *testing.T) {
isCyclic := &task.Executor{
Tasks: map[string]*task.Task{
"task-a": &task.Task{
Deps: []string{"task-b"},
},
"task-b": &task.Task{
Deps: []string{"task-a"},
},
},
}
if !isCyclic.HasCyclicDep() {
t.Error("Task should be cyclic")
}
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{},
},
}
if isNotCyclic.HasCyclicDep() {
t.Error("Task should not be cyclic")
}
}