package oltp
import (
"strings"
"testing"
)
// A dot separates subject tokens wherever a repository's events travel,
// so a name may hold dots only between non-empty parts: "a." and "a..b"
// would put an empty token in a subject that no exact filter can name,
// and a repository nobody can address cannot be deleted either.
func TestARepositoryNameHasNoEmptyDotSegment(t *testing.T) {
for _, name := range []string{"a", "a.b", "a-b_c.d.e9", "A1", strings.Repeat("x", 64)} {
if !RepoName.MatchString(name) {
t.Errorf("%q refused", name)
}
}
for _, name := range []string{"", ".a", "a.", "a..b", "a.b.", "-a", "a/b", "a b", "a*", "a>", strings.Repeat("x", 65)} {
if RepoName.MatchString(name) {
t.Errorf("%q accepted", name)
}
}
}