package main import "testing" // The grant must mean what it says: a prefix Redis would read as a pattern grants keyspace nobody // saw in the manifest. func TestAPrefixThatIsAPatternIsRefused(t *testing.T) { for _, bad := range []string{"", "pho*", "a?b", "x[yz]", "a b", "brace{s}"} { if err := usablePrefix(bad); err == nil { t.Errorf("%q was accepted, and would match more keyspace than it names", bad) } } for _, fine := range []string{"photos", "mesh_laptop_realapp", "a-b.c_d"} { if err := usablePrefix(fine); err != nil { t.Errorf("%q was refused and names exactly itself: %v", fine, err) } } }