Commit 004ff6f433
Verified · cmc
Layout: unified · split
cmd/gitbay/summaries_test.go +18
| @@ -65,3 +65,21 @@ func TestGroupsSayWhatTheServerSays(t *testing.T) { | |||
| 65 | } | 65 | } |
| 66 | } | 66 | } |
| 67 | } | 67 | } |
| 68 | |||
| 69 | // aliasGroupNames is kept by hand because the CLI has no registry to | ||
| 70 | // consult; this fails when it drifts from internal/control's nounAliases | ||
| 71 | // keys instead of silently falling back to the registered forms (#267). | ||
| 72 | func TestAliasGroupNamesMatchServer(t *testing.T) { | ||
| 73 | want := map[string]bool{} | ||
| 74 | for _, name := range control.NounAliasNames() { | ||
| 75 | want[name] = true | ||
| 76 | } | ||
| 77 | if len(aliasGroupNames) != len(want) { | ||
| 78 | t.Fatalf("aliasGroupNames has %d entries, server has %d", len(aliasGroupNames), len(want)) | ||
| 79 | } | ||
| 80 | for name := range want { | ||
| 81 | if !aliasGroupNames[name] { | ||
| 82 | t.Errorf("aliasGroupNames is missing %q", name) | ||
| 83 | } | ||
| 84 | } | ||
| 85 | } | ||
internal/control/help.go +10
| @@ -91,6 +91,16 @@ var nounAliases = map[string][]nounAlias{ | |||
| 91 | }, | 91 | }, |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | // NounAliasNames returns the keys of nounAliases, for the CLI's own | ||
| 95 | // aliasGroupNames agreement test. | ||
| 96 | func NounAliasNames() []string { | ||
| 97 | names := make([]string, 0, len(nounAliases)) | ||
| 98 | for name := range nounAliases { | ||
| 99 | names = append(names, name) | ||
| 100 | } | ||
| 101 | return names | ||
| 102 | } | ||
| 103 | |||
| 94 | // helpEntry is one row of the registry as help reports it. | 104 | // helpEntry is one row of the registry as help reports it. |
| 95 | type helpEntry struct { | 105 | type helpEntry struct { |
| 96 | Path string `json:"path"` | 106 | Path string `json:"path"` |