(t *testing.T)
| 271 | } |
| 272 | |
| 273 | func TestJSONHelpManifestV1MachineFields(t *testing.T) { |
| 274 | put := jsonCommandManifestFor(putCmd) |
| 275 | if put.ManifestVersion != commandManifestVersion { |
| 276 | t.Fatalf("manifest_version = %q, want %q", put.ManifestVersion, commandManifestVersion) |
| 277 | } |
| 278 | assertJSONHelpArg(t, put.Args, "source", true, "local_path", true) |
| 279 | assertJSONHelpArg(t, put.Args, "target", false, "dropbox_path", false) |
| 280 | assertStringSliceEqual(t, "put --if-exists enum", jsonHelpFlagByName(t, put.Flags, "if-exists").EnumValues, []string{"overwrite", "skip", "fail"}) |
| 281 | if !put.StdinStdout.ReadsStdin || put.StdinStdout.WritesBinaryStdout { |
| 282 | t.Fatalf("put stdin_stdout = %+v, want stdin only", put.StdinStdout) |
| 283 | } |
| 284 | assertStringSliceEqual(t, "put warning codes", put.WarningCodes, []string{jsonWarningCodeSkippedSymlink}) |
| 285 | assertStringSliceEqual(t, "put result statuses", put.ResultStatuses, []string{"created", "existing", "skipped", "uploaded"}) |
| 286 | assertStringSliceEqual(t, "put result kinds", put.ResultKinds, []string{"file", "folder"}) |
| 287 | assertStringSliceEqual(t, "put scopes", put.DropboxScopes, []string{"files.content.write", "files.metadata.read"}) |
| 288 | if put.ScopeAccuracy != commandManifestScopeAccuracyBestEffort { |
| 289 | t.Fatalf("scope_accuracy = %q, want %q", put.ScopeAccuracy, commandManifestScopeAccuracyBestEffort) |
| 290 | } |
| 291 | if put.SchemaRefs.CommandContract != "docs/json-schema/v1/commands.json#/commands/put" { |
| 292 | t.Fatalf("put command_contract = %q", put.SchemaRefs.CommandContract) |
| 293 | } |
| 294 | if put.SchemaRefs.CommandSuccessSchema != "docs/json-schema/v1/commands.schema.json#/$defs/command_put" { |
| 295 | t.Fatalf("put command_success_schema = %q", put.SchemaRefs.CommandSuccessSchema) |
| 296 | } |
| 297 | if len(put.Examples) == 0 { |
| 298 | t.Fatal("put examples = empty, want examples") |
| 299 | } |
| 300 | |
| 301 | if put.InputSchema.Type != "object" || put.InputSchema.AdditionalProperties { |
| 302 | t.Fatalf("put input_schema = %+v, want strict object", put.InputSchema) |
| 303 | } |
| 304 | assertStringSliceEqual(t, "put input_schema required", put.InputSchema.Required, []string{"source"}) |
| 305 | assertJSONHelpInputProperty(t, put.InputSchema, "source", "string", "arg", "source", "local_path") |
| 306 | if !put.InputSchema.Properties["source"].XStreamDash { |
| 307 | t.Fatal("put source x-stream-dash = false, want true") |
| 308 | } |
| 309 | assertJSONHelpInputProperty(t, put.InputSchema, "target", "string", "arg", "target", "dropbox_path") |
| 310 | ifExists := assertJSONHelpInputProperty(t, put.InputSchema, "if_exists", "string", "flag", "if-exists", "enum") |
| 311 | assertStringSliceEqual(t, "put input_schema if_exists enum", ifExists.Enum, []string{"fail", "overwrite", "skip"}) |
| 312 | if ifExists.Default != "overwrite" { |
| 313 | t.Fatalf("put if_exists default = %#v, want overwrite", ifExists.Default) |
| 314 | } |
| 315 | recursive := assertJSONHelpInputProperty(t, put.InputSchema, "recursive", "boolean", "flag", "recursive", "boolean") |
| 316 | if recursive.Default != false { |
| 317 | t.Fatalf("put recursive default = %#v, want false", recursive.Default) |
| 318 | } |
| 319 | if _, ok := put.InputSchema.Properties["help"]; ok { |
| 320 | t.Fatal("put input_schema contains help flag") |
| 321 | } |
| 322 | if _, ok := put.InputSchema.Properties["output"]; ok { |
| 323 | t.Fatal("put input_schema contains output flag") |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | func TestJSONHelpManifestV1SelectedCommandMetadata(t *testing.T) { |
| 328 | get := jsonCommandManifestFor(getCmd) |
nothing calls this directly
no test coverage detected