MCPcopy Create free account
hub / github.com/Mirantis/cri-dockerd / TestPullWithJSONError

Function TestPullWithJSONError

core/image_test.go:140–170  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

138}
139
140func 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}

Callers

nothing calls this directly

Calls 5

newTestDockerServiceFunction · 0.85
getTestCTXFunction · 0.85
InjectErrorMethod · 0.80
PullImageMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…