(t *testing.T)
| 47 | } |
| 48 | |
| 49 | func 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 | |
| 93 | func TestAccountLookupJSONUsesAccountID(t *testing.T) { |
| 94 | cmd, stdout := testAccountCmd() |
nothing calls this directly
no test coverage detected