mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-22 16:34:32 +01:00
7756c9a55c
refs #136 refs #140
43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
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"}},
|
|
{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)
|
|
}
|
|
}
|
|
}
|