MCPcopy Create free account
hub / github.com/dropbox/dbxcli / TestVersionJSONOutputsVersionInfo

Function TestVersionJSONOutputsVersionInfo

cmd/version_test.go:37–71  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func TestVersionJSONOutputsVersionInfo(t *testing.T) {
38 cmd := NewVersionCommand("1.2.3")
39 stdout := &bytes.Buffer{}
40 cmd.SetOut(stdout)
41 cmd.Flags().String(outputFlag, "json", "")
42 stubDropboxVersion(t, "sdk-test", "spec-test")
43
44 if err := versionCommand(cmd, "1.2.3"); err != nil {
45 t.Fatalf("versionCommand returned error: %v", err)
46 }
47
48 var got versionOperationOutputForTest
49 if err := json.NewDecoder(bytes.NewReader(stdout.Bytes())).Decode(&got); err != nil {
50 t.Fatalf("decode JSON output: %v\noutput: %s", err, stdout.String())
51 }
52 if got.Input == nil || len(got.Input) != 0 {
53 t.Fatalf("input = %#v, want empty object", got.Input)
54 }
55 if got.Warnings == nil || len(got.Warnings) != 0 {
56 t.Fatalf("warnings = %#v, want empty array", got.Warnings)
57 }
58 if len(got.Results) != 1 {
59 t.Fatalf("results length = %d, want 1", len(got.Results))
60 }
61 result := got.Results[0]
62 if result.Kind != versionKindVersion {
63 t.Fatalf("kind = %q, want %q", result.Kind, versionKindVersion)
64 }
65 if result.Input == nil || len(result.Input) != 0 {
66 t.Fatalf("result input = %#v, want empty object", result.Input)
67 }
68 if result.Result.Version != "1.2.3" || result.Result.SDKVersion != "sdk-test" || result.Result.SpecVersion != "spec-test" {
69 t.Fatalf("result = %#v, want version info", result.Result)
70 }
71}
72
73func TestVersionCommandSupportsStructuredOutput(t *testing.T) {
74 if !commandSupportsStructuredOutput(NewVersionCommand("1.2.3")) {

Callers

nothing calls this directly

Calls 3

NewVersionCommandFunction · 0.85
stubDropboxVersionFunction · 0.85
versionCommandFunction · 0.85

Tested by

no test coverage detected