(t *testing.T)
| 138 | } |
| 139 | |
| 140 | func TestPullWithJSONError(t *testing.T) { |
| 141 | ds, fakeDocker, _ := newTestDockerService() |
| 142 | tests := map[string]struct { |
| 143 | image *runtimeapi.ImageSpec |
| 144 | err error |
| 145 | expectedError string |
| 146 | }{ |
| 147 | "Json error": { |
| 148 | &runtimeapi.ImageSpec{Image: "ubuntu"}, |
| 149 | &jsonmessage.JSONError{Code: 50, Message: "Json error"}, |
| 150 | "Json error", |
| 151 | }, |
| 152 | "Bad gateway": { |
| 153 | &runtimeapi.ImageSpec{Image: "ubuntu"}, |
| 154 | &jsonmessage.JSONError{ |
| 155 | Code: 502, |
| 156 | Message: "<!doctype html>\n<html class=\"no-js\" lang=\"\">\n <head>\n </head>\n <body>\n <h1>Oops, there was an error!</h1>\n <p>We have been contacted of this error, feel free to check out <a href=\"http://status.docker.com/\">status.docker.com</a>\n to see if there is a bigger issue.</p>\n\n </body>\n</html>", |
| 157 | }, |
| 158 | "RegistryUnavailable", |
| 159 | }, |
| 160 | } |
| 161 | for key, test := range tests { |
| 162 | fakeDocker.InjectError("pull", test.err) |
| 163 | _, err := ds.PullImage( |
| 164 | getTestCTX(), |
| 165 | &runtimeapi.PullImageRequest{Image: test.image, Auth: &runtimeapi.AuthConfig{}}, |
| 166 | ) |
| 167 | require.Error(t, err, fmt.Sprintf("TestCase [%s]", key)) |
| 168 | assert.Contains(t, err.Error(), test.expectedError) |
| 169 | } |
| 170 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…