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

Function TestDuJSONIndividualAllocation

cmd/du_test.go:39–72  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

37}
38
39func 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
74func TestDuJSONTeamAllocation(t *testing.T) {
75 cmd, stdout := testDuCmd()

Callers

nothing calls this directly

Calls 6

testDuCmdFunction · 0.85
setDuOutputJSONFunction · 0.85
stubUsersClientFunction · 0.85
individualSpaceUsageFunction · 0.85
duFunction · 0.85
decodeDuOutputFunction · 0.85

Tested by

no test coverage detected