| 47 | } |
| 48 | |
| 49 | func TestInvalidIdentifiers(t *testing.T) { |
| 50 | for _, input := range []string{ |
| 51 | "", |
| 52 | ".foo..foo", |
| 53 | "foo/foo", |
| 54 | "foo/..", |
| 55 | "foo..foo", |
| 56 | "foo.-boo", |
| 57 | "-foo.boo", |
| 58 | "foo.boo-", |
| 59 | "but__only_tasteful_underscores", |
| 60 | "zn--e9.org", // or something like it! |
| 61 | "default--default", |
| 62 | strings.Repeat("a", maxLength+1), |
| 63 | } { |
| 64 | |
| 65 | t.Run(input, func(t *testing.T) { |
| 66 | if err := Validate(input); err == nil { |
| 67 | t.Fatal("expected invalid error") |
| 68 | } else if !errdefs.IsInvalidArgument(err) { |
| 69 | t.Fatal("error should be an invalid identifier error") |
| 70 | } |
| 71 | }) |
| 72 | } |
| 73 | } |