MCPcopy Index your code
hub / github.com/docker/cli / TestDiskUsageContextFormatWrite

Function TestDiskUsageContextFormatWrite

cli/command/formatter/disk_usage_test.go:11–119  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestDiskUsageContextFormatWrite(t *testing.T) {
12 cases := []struct {
13 context DiskUsageContext
14 expected string
15 }{
16 // Check default output format (verbose and non-verbose mode) for table headers
17 {
18 DiskUsageContext{
19 Context: Context{
20 Format: NewDiskUsageFormat("table", false),
21 },
22 Verbose: false,
23 },
24 `TYPE TOTAL ACTIVE SIZE RECLAIMABLE
25Images 0 0 0B 0B
26Containers 0 0 0B 0B
27Local Volumes 0 0 0B 0B
28Build Cache 0 0 0B 0B
29`,
30 },
31 {
32 DiskUsageContext{Verbose: true, Context: Context{Format: NewDiskUsageFormat("table", true)}},
33 `Images space usage:
34
35REPOSITORY TAG IMAGE ID CREATED SIZE SHARED SIZE UNIQUE SIZE CONTAINERS
36
37Containers space usage:
38
39CONTAINER ID IMAGE COMMAND LOCAL VOLUMES SIZE CREATED STATUS NAMES
40
41Local Volumes space usage:
42
43VOLUME NAME LINKS SIZE
44
45Build cache usage: 0B
46
47CACHE ID CACHE TYPE SIZE CREATED LAST USED USAGE SHARED
48`,
49 },
50 {
51 DiskUsageContext{Verbose: true, Context: Context{Format: NewDiskUsageFormat("raw", true)}},
52 ``,
53 },
54 {
55 DiskUsageContext{Verbose: true, Context: Context{Format: NewDiskUsageFormat("{{json .}}", true)}},
56 `{"Images":[],"Containers":[],"Volumes":[],"BuildCache":[]}`,
57 },
58 // Errors
59 {
60 DiskUsageContext{
61 Context: Context{
62 Format: "{{InvalidFunction}}",
63 },
64 },
65 `template parsing error: template: :1: function "InvalidFunction" not defined`,
66 },
67 {
68 DiskUsageContext{

Callers

nothing calls this directly

Calls 5

NewDiskUsageFormatFunction · 0.85
GetMethod · 0.65
StringMethod · 0.65
WriteMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…