shad-go/tools/testtool/commands/deadlines_test.go

53 lines
1.2 KiB
Go
Raw Normal View History

2020-02-12 22:54:25 +00:00
package commands
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestDeadlines(t *testing.T) {
d, err := loadDeadlines("../../../.manytask.yml")
2020-02-12 22:54:25 +00:00
require.NoError(t, err)
require.NotEmpty(t, d)
_, sum := d.FindTask("sum")
require.NotNil(t, sum)
require.Equal(t, "sum", sum.Name)
}
2020-02-12 23:28:27 +00:00
func TestDetectChange(t *testing.T) {
2022-04-15 14:58:09 +00:00
for _, tc := range []struct {
name string
deadlines string
changedFiles []string
changedTasks []string
}{
{
name: "sum", // Original deadlines file with sum task.
deadlines: "../../../.manytask.yml",
2022-04-15 14:58:09 +00:00
changedFiles: []string{"sum/sum.go", "testtool/foo.go", "README.md"},
changedTasks: []string{"sum"},
},
{
name: "tarstreamtest", // Deadlines file with tarstreamtest task.
deadlines: "../testdata/deadlines/.manytask.yml",
2022-04-15 14:58:09 +00:00
changedFiles: []string{
"sum/sum.go",
"testtool/foo.go",
"distbuild/pkg/tarstream/stream.go",
"README.md",
},
changedTasks: []string{"sum", "tarstreamtest"},
},
} {
t.Run(tc.name, func(t *testing.T) {
d, err := loadDeadlines(tc.deadlines)
require.NoError(t, err)
2020-02-12 23:28:27 +00:00
2022-04-15 14:58:09 +00:00
changed := findChangedTasks(d, tc.changedFiles)
require.Equal(t, tc.changedTasks, changed)
})
}
2020-02-12 23:28:27 +00:00
}