courgette/internal/workflow/dependencies_test.go

48 lines
991 B
Go

package workflow
import (
"reflect"
"testing"
)
func TestSplitFlatTreeIntoGroupsProducesListOfLevels(t *testing.T) {
flatTree := map[string][]string{
"": []string{"a"},
"a": []string{"b"},
"b": []string{"c"},
"c": []string{},
}
levels := SplitFlatTreeIntoGroups(flatTree)
expectedLevels := [][]string{
[]string{"a"},
[]string{"b"},
[]string{"c"},
}
if !reflect.DeepEqual(levels, expectedLevels) {
t.Errorf("Expected levels to be %+v, got %+v instead.", expectedLevels, levels)
}
}
func TestSplitFlatTreeIntoGroupsProducesListOfLevelsIfMultiparent(t *testing.T) {
flatTree := map[string][]string{
"": []string{"a"},
"a": []string{"b", "c"},
"b": []string{"c"},
"c": []string{},
}
levels := SplitFlatTreeIntoGroups(flatTree)
expectedLevels := [][]string{
[]string{"a"},
[]string{"b"},
[]string{"c"},
}
if !reflect.DeepEqual(levels, expectedLevels) {
t.Errorf("Expected levels to be %+v, got %+v instead.", expectedLevels, levels)
}
}