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

Function TestNewHistoryCommandSuccess

cli/command/image/history_test.go:54–134  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

52}
53
54func TestNewHistoryCommandSuccess(t *testing.T) {
55 testCases := []struct {
56 name string
57 args []string
58 imageHistoryFunc func(img string, options ...client.ImageHistoryOption) (client.ImageHistoryResult, error)
59 }{
60 {
61 name: "simple",
62 args: []string{"image:tag"},
63 imageHistoryFunc: func(string, ...client.ImageHistoryOption) (client.ImageHistoryResult, error) {
64 return client.ImageHistoryResult{
65 Items: []image.HistoryResponseItem{{
66 ID: "1234567890123456789",
67 Created: time.Now().Unix(),
68 Comment: "none",
69 }},
70 }, nil
71 },
72 },
73 {
74 name: "quiet",
75 args: []string{"--quiet", "image:tag"},
76 },
77 {
78 name: "non-human",
79 args: []string{"--human=false", "image:tag"},
80 imageHistoryFunc: func(string, ...client.ImageHistoryOption) (client.ImageHistoryResult, error) {
81 return client.ImageHistoryResult{
82 Items: []image.HistoryResponseItem{{
83 ID: "abcdef",
84 Created: time.Date(2017, 1, 1, 12, 0, 3, 0, time.UTC).Unix(),
85 CreatedBy: "rose",
86 Comment: "new history item!",
87 }},
88 }, nil
89 },
90 },
91 {
92 name: "quiet-no-trunc",
93 args: []string{"--quiet", "--no-trunc", "image:tag"},
94 imageHistoryFunc: func(string, ...client.ImageHistoryOption) (client.ImageHistoryResult, error) {
95 return client.ImageHistoryResult{
96 Items: []image.HistoryResponseItem{{
97 ID: "1234567890123456789",
98 Created: time.Now().Unix(),
99 }},
100 }, nil
101 },
102 },
103 {
104 name: "platform",
105 args: []string{"--platform", "linux/amd64", "image:tag"},
106 imageHistoryFunc: func(img string, options ...client.ImageHistoryOption) (client.ImageHistoryResult, error) {
107 // FIXME(thaJeztah): need to find appropriate way to test the result of "ImageHistoryWithPlatform" being applied
108 assert.Check(t, len(options) > 0) // can be 1 or two depending on whether a terminal is attached :/
109 // assert.Check(t, is.Contains(options, client.ImageHistoryWithPlatform(ocispec.Platform{OS: "linux", Architecture: "amd64"})))
110 return client.ImageHistoryResult{
111 Items: []image.HistoryResponseItem{{

Callers

nothing calls this directly

Calls 5

OutBufferMethod · 0.95
newHistoryCommandFunction · 0.85
SetArgsMethod · 0.80
StringMethod · 0.65
SetOutMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…