(t *testing.T)
| 37 | } |
| 38 | |
| 39 | func TestDuJSONIndividualAllocation(t *testing.T) { |
| 40 | cmd, stdout := testDuCmd() |
| 41 | setDuOutputJSON(t, cmd) |
| 42 | stubUsersClient(t, &mockUsersClient{ |
| 43 | getSpaceUsageFn: func() (*users.SpaceUsage, error) { |
| 44 | return individualSpaceUsage(), nil |
| 45 | }, |
| 46 | }) |
| 47 | |
| 48 | if err := du(cmd, nil); err != nil { |
| 49 | t.Fatalf("du returned error: %v", err) |
| 50 | } |
| 51 | |
| 52 | got := decodeDuOutput(t, stdout) |
| 53 | if len(got.Input) != 0 { |
| 54 | t.Fatalf("input = %#v, want empty object", got.Input) |
| 55 | } |
| 56 | result := got.Results[0] |
| 57 | if result.Kind != duKindSpaceUsage { |
| 58 | t.Fatalf("kind = %q, want space_usage", result.Kind) |
| 59 | } |
| 60 | if len(result.Input) != 0 { |
| 61 | t.Fatalf("result input = %#v, want empty object", result.Input) |
| 62 | } |
| 63 | if result.Result.Used != 1024 { |
| 64 | t.Fatalf("used = %d, want 1024", result.Result.Used) |
| 65 | } |
| 66 | if result.Result.Allocation.Type != "individual" || result.Result.Allocation.Allocated == nil || *result.Result.Allocation.Allocated != 2048 { |
| 67 | t.Fatalf("allocation = %#v, want individual allocation", result.Result.Allocation) |
| 68 | } |
| 69 | if result.Result.Allocation.Used != nil { |
| 70 | t.Fatalf("allocation.used = %#v, want omitted for individual allocation", result.Result.Allocation.Used) |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | func TestDuJSONTeamAllocation(t *testing.T) { |
| 75 | cmd, stdout := testDuCmd() |
nothing calls this directly
no test coverage detected