(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestAccountCurrentTextUsesCommandOutput(t *testing.T) { |
| 17 | cmd, stdout := testAccountCmd() |
| 18 | setCurrentAuthContextForTest(t, &authContext{Source: authSourceSaved, Refreshable: true, AuthFile: authFileDefault}) |
| 19 | stubUsersClient(t, &mockUsersClient{ |
| 20 | getCurrentAccountFn: func() (*users.FullAccount, error) { |
| 21 | return testFullAccount(), nil |
| 22 | }, |
| 23 | }) |
| 24 | |
| 25 | if err := account(cmd, nil); err != nil { |
| 26 | t.Fatalf("account returned error: %v", err) |
| 27 | } |
| 28 | output := stdout.String() |
| 29 | if !strings.Contains(output, "Logged in as Test User <test@example.com>") { |
| 30 | t.Fatalf("stdout = %q, want current account text output", output) |
| 31 | } |
| 32 | if !strings.Contains(output, "Account Type:") { |
| 33 | t.Fatalf("stdout = %q, want account type", output) |
| 34 | } |
| 35 | if !strings.Contains(output, "Auth:") || !strings.Contains(output, "Source: saved credentials") || !strings.Contains(output, "Refreshable: true") || !strings.Contains(output, "Auth File: default") { |
| 36 | t.Fatalf("stdout = %q, want auth context", output) |
| 37 | } |
| 38 | if !strings.Contains(output, "Profile Photo URL:") { |
| 39 | t.Fatalf("stdout = %q, want Profile Photo URL label", output) |
| 40 | } |
| 41 | if strings.Contains(output, "Profile Photo Url:") { |
| 42 | t.Fatalf("stdout = %q, want URL acronym casing", output) |
| 43 | } |
| 44 | if strings.Contains(output, "Acting As:") { |
| 45 | t.Fatalf("stdout = %q, want no Acting As section", output) |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | func TestAccountCurrentJSONOutputsAccount(t *testing.T) { |
| 50 | cmd, stdout := testAccountCmd() |
nothing calls this directly
no test coverage detected