(t *testing.T)
| 52 | } |
| 53 | |
| 54 | func 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{{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…