2019-03-20 23:01:24 +01:00
|
|
|
package job
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestValidateReceivingSidesDoNotOverlap(t *testing.T) {
|
|
|
|
type testCase struct {
|
|
|
|
err bool
|
|
|
|
input []string
|
|
|
|
}
|
|
|
|
tcs := []testCase{
|
|
|
|
{false, nil},
|
|
|
|
{false, []string{}},
|
|
|
|
{false, []string{""}}, // not our job to determine valid paths
|
|
|
|
{false, []string{"a"}},
|
|
|
|
{false, []string{"some/path"}},
|
|
|
|
{false, []string{"zroot/sink1", "zroot/sink2", "zroot/sink3"}},
|
2020-01-30 01:59:57 +01:00
|
|
|
{false, []string{"zroot/foo", "zroot/foobar"}},
|
2019-03-20 23:01:24 +01:00
|
|
|
{true, []string{"zroot/b", "zroot/b"}},
|
|
|
|
{true, []string{"zroot/foo", "zroot/foo/bar", "zroot/baz"}},
|
|
|
|
{false, []string{"a/x", "b/x"}},
|
|
|
|
{false, []string{"a", "b"}},
|
|
|
|
{true, []string{"a", "a"}},
|
|
|
|
{true, []string{"a/x/y", "a/x"}},
|
|
|
|
{true, []string{"a/x", "a/x/y"}},
|
|
|
|
{true, []string{"a/x", "b/x", "a/x/y"}},
|
|
|
|
{true, []string{"a", "a/b", "a/c", "a/b"}},
|
|
|
|
{true, []string{"a/b", "a/c", "a/b", "a/d", "a/c"}},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range tcs {
|
|
|
|
t.Logf("input: %v", tc.input)
|
|
|
|
err := validateReceivingSidesDoNotOverlap(tc.input)
|
|
|
|
if tc.err {
|
|
|
|
assert.Error(t, err)
|
|
|
|
} else {
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|