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

Function TestAccountCurrentJSONOutputsAccount

cmd/account_test.go:49–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47}
48
49func TestAccountCurrentJSONOutputsAccount(t *testing.T) {
50 cmd, stdout := testAccountCmd()
51 setAccountOutputJSON(t, cmd)
52 setCurrentAuthContextForTest(t, &authContext{Source: authSourceSaved, Refreshable: true, AuthFile: authFileDefault})
53 stubUsersClient(t, &mockUsersClient{
54 getCurrentAccountFn: func() (*users.FullAccount, error) {
55 return testFullAccount(), nil
56 },
57 })
58
59 if err := account(cmd, nil); err != nil {
60 t.Fatalf("account returned error: %v", err)
61 }
62
63 got := decodeAccountOutput(t, stdout)
64 if got.Input.AccountID != "" {
65 t.Fatalf("input.account_id = %q, want empty for current account", got.Input.AccountID)
66 }
67 result := got.Results[0]
68 if result.Kind != accountKindAccount {
69 t.Fatalf("kind = %q, want account", result.Kind)
70 }
71 if result.Input.AccountID != "" {
72 t.Fatalf("result input.account_id = %q, want empty for current account", result.Input.AccountID)
73 }
74 account := result.Result
75 if account.Type != "full" || account.AccountID != "dbid:current" || account.Email != "test@example.com" {
76 t.Fatalf("account = %#v, want current full account", account)
77 }
78 if account.Name == nil || account.Name.DisplayName != "Test User" {
79 t.Fatalf("name = %#v, want display name", account.Name)
80 }
81 if account.AccountType != "business" {
82 t.Fatalf("account_type = %q, want business", account.AccountType)
83 }
84 if account.IsPaired == nil || *account.IsPaired {
85 t.Fatalf("is_paired = %#v, want false pointer", account.IsPaired)
86 }
87 if account.Team == nil || account.Team.ID != "team-id" || account.Team.MemberID != "dbmid:member" {
88 t.Fatalf("team = %#v, want team metadata", account.Team)
89 }
90 assertAccountAuth(t, account.Auth, authSourceSaved, true, authFileDefault)
91}
92
93func TestAccountLookupJSONUsesAccountID(t *testing.T) {
94 cmd, stdout := testAccountCmd()

Callers

nothing calls this directly

Calls 8

testAccountCmdFunction · 0.85
setAccountOutputJSONFunction · 0.85
stubUsersClientFunction · 0.85
testFullAccountFunction · 0.85
accountFunction · 0.85
decodeAccountOutputFunction · 0.85
assertAccountAuthFunction · 0.85

Tested by

no test coverage detected