(t *testing.T)
| 188 | } |
| 189 | |
| 190 | func TestJSONHelpManifestFields(t *testing.T) { |
| 191 | stdout, _, err := executeJSONHelpTestRoot(t, []string{"--help", "--output=json"}) |
| 192 | if err != nil { |
| 193 | t.Fatalf("Execute returned error: %v", err) |
| 194 | } |
| 195 | got := decodeJSONHelpOutput(t, stdout) |
| 196 | |
| 197 | ls := jsonHelpManifestByPath(t, got, "ls") |
| 198 | if !ls.SupportsStructuredOutput { |
| 199 | t.Fatal("ls supports_structured_output = false, want true") |
| 200 | } |
| 201 | assertStringSliceEqual(t, "ls auth modes", ls.AuthModes, []string{"personal", "team-access"}) |
| 202 | if ls.DestructiveLevel != destructiveLevelNone { |
| 203 | t.Fatalf("ls destructive_level = %q, want none", ls.DestructiveLevel) |
| 204 | } |
| 205 | assertJSONHelpFlagNames(t, ls.Flags, []string{"as-member", "help", "include-deleted", "output", "verbose"}) |
| 206 | if jsonHelpHasFlag(ls.Flags, "domain") { |
| 207 | t.Fatal("hidden domain flag should be omitted") |
| 208 | } |
| 209 | outputFlag := jsonHelpFlagByName(t, ls.Flags, "output") |
| 210 | if !outputFlag.Inherited { |
| 211 | t.Fatal("output flag should be inherited on ls") |
| 212 | } |
| 213 | if outputFlag.Type != "string" || outputFlag.Default != "text" { |
| 214 | t.Fatalf("output flag = %+v, want string text default", outputFlag) |
| 215 | } |
| 216 | |
| 217 | login := jsonHelpManifestByPath(t, got, "login") |
| 218 | if login.SupportsStructuredOutput { |
| 219 | t.Fatal("login supports_structured_output = true, want false") |
| 220 | } |
| 221 | if len(login.AuthModes) != 0 { |
| 222 | t.Fatalf("login auth_modes = %v, want empty", login.AuthModes) |
| 223 | } |
| 224 | |
| 225 | logout := jsonHelpManifestByPath(t, got, "logout") |
| 226 | if !logout.SupportsStructuredOutput { |
| 227 | t.Fatal("logout supports_structured_output = false, want true") |
| 228 | } |
| 229 | if len(logout.AuthModes) != 0 { |
| 230 | t.Fatalf("logout auth_modes = %v, want empty", logout.AuthModes) |
| 231 | } |
| 232 | |
| 233 | rm := jsonHelpManifestByPath(t, got, "rm") |
| 234 | if rm.DestructiveLevel != destructiveLevelDelete { |
| 235 | t.Fatalf("rm destructive_level = %q, want delete", rm.DestructiveLevel) |
| 236 | } |
| 237 | |
| 238 | teamInfo := jsonHelpManifestByPath(t, got, "team info") |
| 239 | assertStringSliceEqual(t, "team info auth modes", teamInfo.AuthModes, []string{"team-manage"}) |
| 240 | |
| 241 | teamAdd := jsonHelpManifestByPath(t, got, "team add-member") |
| 242 | if teamAdd.DestructiveLevel != destructiveLevelAdmin { |
| 243 | t.Fatalf("team add-member destructive_level = %q, want admin", teamAdd.DestructiveLevel) |
| 244 | } |
| 245 | |
| 246 | helpFromRoot := jsonHelpManifestByPath(t, got, "help") |
| 247 | if !strings.Contains(helpFromRoot.Use, "[flags]") { |
nothing calls this directly
no test coverage detected