(t *testing.T)
| 325 | } |
| 326 | |
| 327 | func TestJSONHelpManifestV1SelectedCommandMetadata(t *testing.T) { |
| 328 | get := jsonCommandManifestFor(getCmd) |
| 329 | assertJSONHelpArg(t, get.Args, "source", true, "dropbox_path", false) |
| 330 | assertJSONHelpArg(t, get.Args, "target", false, "local_path", true) |
| 331 | if !get.StdinStdout.WritesBinaryStdout { |
| 332 | t.Fatalf("get stdin_stdout = %+v, want binary stdout support", get.StdinStdout) |
| 333 | } |
| 334 | |
| 335 | cp := jsonCommandManifestFor(cpCmd) |
| 336 | assertJSONHelpArg(t, cp.Args, "source", true, "dropbox_path", false) |
| 337 | if !jsonHelpArgByName(t, cp.Args, "source").Variadic { |
| 338 | t.Fatal("cp source variadic = false, want true") |
| 339 | } |
| 340 | assertStringSliceEqual(t, "cp --if-exists enum", jsonHelpFlagByName(t, cp.Flags, "if-exists").EnumValues, []string{"fail", "skip"}) |
| 341 | assertStringSliceEqual(t, "cp input_schema required", cp.InputSchema.Required, []string{"source", "target"}) |
| 342 | source := assertJSONHelpInputProperty(t, cp.InputSchema, "source", "array", "arg", "source", "dropbox_path") |
| 343 | if source.Items == nil || source.Items.Type != "string" { |
| 344 | t.Fatalf("cp source items = %+v, want string items", source.Items) |
| 345 | } |
| 346 | if source.MinItems != 1 { |
| 347 | t.Fatalf("cp source minItems = %d, want 1", source.MinItems) |
| 348 | } |
| 349 | assertJSONHelpInputProperty(t, cp.InputSchema, "target", "string", "arg", "target", "dropbox_path") |
| 350 | cpIfExists := assertJSONHelpInputProperty(t, cp.InputSchema, "if_exists", "string", "flag", "if-exists", "enum") |
| 351 | assertStringSliceEqual(t, "cp input_schema if_exists enum", cpIfExists.Enum, []string{"fail", "skip"}) |
| 352 | |
| 353 | create := jsonCommandManifestFor(shareLinkCreateCmd) |
| 354 | assertStringSliceEqual(t, "share-link create audience enum", jsonHelpFlagByName(t, create.Flags, "audience").EnumValues, []string{"public", "team", "members", "no-one"}) |
| 355 | assertStringSliceEqual(t, "share-link create allow conflict", jsonHelpFlagByName(t, create.Flags, "allow-download").Conflicts, []string{"disallow-download"}) |
| 356 | if !jsonHelpFlagByName(t, create.Flags, "password").Sensitive { |
| 357 | t.Fatal("share-link create password sensitive = false, want true") |
| 358 | } |
| 359 | if !jsonHelpFlagByName(t, create.Flags, "password-prompt").MayPrompt { |
| 360 | t.Fatal("share-link create password-prompt may_prompt = false, want true") |
| 361 | } |
| 362 | |
| 363 | update := jsonCommandManifestFor(shareLinkUpdateCmd) |
| 364 | assertStringSliceEqual(t, "share-link update expires conflict", jsonHelpFlagByName(t, update.Flags, "expires").Conflicts, []string{"remove-expiration"}) |
| 365 | assertStringSliceEqual(t, "share-link update remove-password conflict", jsonHelpFlagByName(t, update.Flags, "remove-password").Conflicts, []string{"password", "password-file", "password-prompt"}) |
| 366 | audience := assertJSONHelpInputProperty(t, update.InputSchema, "audience", "string", "flag", "audience", "enum") |
| 367 | assertStringSliceEqual(t, "share-link update input_schema audience enum", audience.Enum, []string{"members", "no-one", "public", "team"}) |
| 368 | expires := assertJSONHelpInputProperty(t, update.InputSchema, "expires", "string", "flag", "expires", "rfc3339_timestamp") |
| 369 | if expires.Format != "date-time" { |
| 370 | t.Fatalf("share-link update expires format = %q, want date-time", expires.Format) |
| 371 | } |
| 372 | removeExpiration := assertJSONHelpInputProperty(t, update.InputSchema, "remove_expiration", "boolean", "flag", "remove-expiration", "boolean") |
| 373 | assertStringSliceEqual(t, "share-link update remove_expiration conflicts", removeExpiration.XConflicts, []string{"expires"}) |
| 374 | password := assertJSONHelpInputProperty(t, update.InputSchema, "password", "string", "flag", "password", "secret") |
| 375 | if !password.XSensitive || !password.WriteOnly { |
| 376 | t.Fatalf("share-link update password sensitivity = %+v, want sensitive writeOnly", password) |
| 377 | } |
| 378 | passwordPrompt := assertJSONHelpInputProperty(t, update.InputSchema, "password_prompt", "boolean", "flag", "password-prompt", "boolean") |
| 379 | if !passwordPrompt.XMayPrompt { |
| 380 | t.Fatal("share-link update password_prompt x-may-prompt = false, want true") |
| 381 | } |
| 382 | |
| 383 | deprecatedListLink := jsonCommandManifestFor(shareListLinksCmd) |
| 384 | if !strings.Contains(deprecatedListLink.Use, "[path]") { |
nothing calls this directly
no test coverage detected