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

Function TestDuJSONTeamAllocation

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

Source from the content-addressed store, hash-verified

72}
73
74func 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
109func TestDuJSONErrorWritesNoOutput(t *testing.T) {
110 cmd, stdout := testDuCmd()

Callers

nothing calls this directly

Calls 6

testDuCmdFunction · 0.85
setDuOutputJSONFunction · 0.85
stubUsersClientFunction · 0.85
teamSpaceUsageFunction · 0.85
duFunction · 0.85
decodeDuOutputFunction · 0.85

Tested by

no test coverage detected