Download this file
| 1 | package setup |
| 2 | |
| 3 | import ( |
| 4 | "errors" |
| 5 | "testing" |
| 6 | ) |
| 7 | |
| 8 | func TestCanonicalRepositoryRequiresFullHubKey(t *testing.T) { |
| 9 | invalid := errors.New("invalid fixture") |
| 10 | for _, raw := range []string{"amadan.net/a", "https://amadan.net/a", "amadan.net", "oficina/site", "github.com/oficina/site"} { |
| 11 | if got, err := CanonicalRepository(raw, invalid); !errors.Is(err, invalid) || got != "" { |
| 12 | t.Errorf("incomplete or non-hub key %q accepted: %q %v", raw, got, err) |
| 13 | } |
| 14 | } |
| 15 | for _, raw := range []string{"amadan.net/oficina/site", "https://amadan.net/oficina/site", " https://amadan.net/oficina/site "} { |
| 16 | if got, err := CanonicalRepository(raw, invalid); err != nil || got != "amadan.net/oficina/site" { |
| 17 | t.Errorf("valid hub key %q: %q %v", raw, got, err) |
| 18 | } |
| 19 | } |
| 20 | } |
| 21 | |