(t *testing.T)
| 77 | } |
| 78 | |
| 79 | func TestNewLoadCommandSuccess(t *testing.T) { |
| 80 | testCases := []struct { |
| 81 | name string |
| 82 | args []string |
| 83 | imageLoadFunc func(input io.Reader, options ...client.ImageLoadOption) (client.ImageLoadResult, error) |
| 84 | }{ |
| 85 | { |
| 86 | name: "simple", |
| 87 | args: []string{}, |
| 88 | imageLoadFunc: func(input io.Reader, options ...client.ImageLoadOption) (client.ImageLoadResult, error) { |
| 89 | // FIXME(thaJeztah): how to mock this? |
| 90 | // return client.ImageLoadResult{ |
| 91 | // Body: io.NopCloser(strings.NewReader(`{"ID":"simple","Status":"success"}`)), |
| 92 | // }, nil |
| 93 | return mockImageLoadResult(`{"ID":"simple","Status":"success"}`), nil |
| 94 | }, |
| 95 | }, |
| 96 | { |
| 97 | name: "input-file", |
| 98 | args: []string{"--input", "testdata/load-command-success.input.txt"}, |
| 99 | imageLoadFunc: func(input io.Reader, options ...client.ImageLoadOption) (client.ImageLoadResult, error) { |
| 100 | // FIXME(thaJeztah): how to mock this? |
| 101 | // return client.ImageLoadResult{Body: io.NopCloser(strings.NewReader(`{"ID":"input-file","Status":"success"}`))}, nil |
| 102 | return mockImageLoadResult(`{"ID":"input-file","Status":"success"}`), nil |
| 103 | }, |
| 104 | }, |
| 105 | { |
| 106 | name: "with-single-platform", |
| 107 | args: []string{"--platform", "linux/amd64"}, |
| 108 | imageLoadFunc: func(input io.Reader, options ...client.ImageLoadOption) (client.ImageLoadResult, error) { |
| 109 | // FIXME(thaJeztah): need to find appropriate way to test the result of "ImageHistoryWithPlatform" being applied |
| 110 | assert.Check(t, len(options) > 0) // can be 1 or two depending on whether a terminal is attached :/ |
| 111 | // assert.Check(t, is.Contains(options, client.ImageHistoryWithPlatform(ocispec.Platform{OS: "linux", Architecture: "amd64"}))) |
| 112 | // FIXME(thaJeztah): how to mock this? |
| 113 | // return client.ImageLoadResult{Body: io.NopCloser(strings.NewReader(`{"ID":"single-platform","Status":"success"}`))}, nil |
| 114 | return mockImageLoadResult(`{"ID":"single-platform","Status":"success"}`), nil |
| 115 | }, |
| 116 | }, |
| 117 | { |
| 118 | name: "with-comma-separated-platforms", |
| 119 | args: []string{"--platform", "linux/amd64,linux/arm64/v8,linux/riscv64"}, |
| 120 | imageLoadFunc: func(input io.Reader, options ...client.ImageLoadOption) (client.ImageLoadResult, error) { |
| 121 | assert.Check(t, len(options) > 0) // can be 1 or two depending on whether a terminal is attached :/ |
| 122 | // FIXME(thaJeztah): how to mock this? |
| 123 | // return client.ImageLoadResult{Body: io.NopCloser(strings.NewReader(`{"ID":"with-comma-separated-platforms","Status":"success"}`))}, nil |
| 124 | return mockImageLoadResult(`{"ID":"with-comma-separated-platforms","Status":"success"}`), nil |
| 125 | }, |
| 126 | }, |
| 127 | { |
| 128 | name: "with-multiple-platform-options", |
| 129 | args: []string{"--platform", "linux/amd64", "--platform", "linux/arm64/v8", "--platform", "linux/riscv64"}, |
| 130 | imageLoadFunc: func(input io.Reader, options ...client.ImageLoadOption) (client.ImageLoadResult, error) { |
| 131 | assert.Check(t, len(options) > 0) // can be 1 or two depending on whether a terminal is attached :/ |
| 132 | // FIXME(thaJeztah): how to mock this? |
| 133 | // return client.ImageLoadResult{Body: io.NopCloser(strings.NewReader(`{"ID":"with-multiple-platform-options","Status":"success"}`))}, nil |
| 134 | return mockImageLoadResult(`{"ID":"with-multiple-platform-options","Status":"success"}`), nil |
| 135 | }, |
| 136 | }, |
nothing calls this directly
no test coverage detected
searching dependent graphs…