(t *testing.T)
| 72 | } |
| 73 | |
| 74 | func TestDuJSONTeamAllocation(t *testing.T) { |
| 75 | cmd, stdout := testDuCmd() |
| 76 | setDuOutputJSON(t, cmd) |
| 77 | stubUsersClient(t, &mockUsersClient{ |
| 78 | getSpaceUsageFn: func() (*users.SpaceUsage, error) { |
| 79 | return teamSpaceUsage(), nil |
| 80 | }, |
| 81 | }) |
| 82 | |
| 83 | if err := du(cmd, nil); err != nil { |
| 84 | t.Fatalf("du returned error: %v", err) |
| 85 | } |
| 86 | |
| 87 | got := decodeDuOutput(t, stdout) |
| 88 | result := got.Results[0] |
| 89 | if result.Kind != duKindSpaceUsage { |
| 90 | t.Fatalf("kind = %q, want space_usage", result.Kind) |
| 91 | } |
| 92 | if result.Result.Used != 4096 { |
| 93 | t.Fatalf("used = %d, want 4096", result.Result.Used) |
| 94 | } |
| 95 | if result.Result.Allocation.Type != "team" { |
| 96 | t.Fatalf("allocation.type = %q, want team", result.Result.Allocation.Type) |
| 97 | } |
| 98 | if result.Result.Allocation.Allocated == nil || *result.Result.Allocation.Allocated != 8192 { |
| 99 | t.Fatalf("allocation.allocated = %#v, want 8192", result.Result.Allocation.Allocated) |
| 100 | } |
| 101 | if result.Result.Allocation.Used == nil || *result.Result.Allocation.Used != 2048 { |
| 102 | t.Fatalf("allocation.used = %#v, want 2048", result.Result.Allocation.Used) |
| 103 | } |
| 104 | if result.Result.Allocation.UserWithinTeamSpaceLimitType != "alert_only" { |
| 105 | t.Fatalf("user_within_team_space_limit_type = %q, want alert_only", result.Result.Allocation.UserWithinTeamSpaceLimitType) |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | func TestDuJSONErrorWritesNoOutput(t *testing.T) { |
| 110 | cmd, stdout := testDuCmd() |
nothing calls this directly
no test coverage detected