(t *testing.T)
| 59 | } |
| 60 | |
| 61 | func TestImageInspectWithPlatform(t *testing.T) { |
| 62 | const expectedURL = "/images/image_id/json" |
| 63 | requestedPlatform := &ocispec.Platform{ |
| 64 | OS: "linux", |
| 65 | Architecture: "arm64", |
| 66 | } |
| 67 | |
| 68 | expectedPlatform, err := encodePlatform(requestedPlatform) |
| 69 | assert.NilError(t, err) |
| 70 | |
| 71 | client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) { |
| 72 | if err := assertRequest(req, http.MethodGet, expectedURL); err != nil { |
| 73 | return nil, err |
| 74 | } |
| 75 | |
| 76 | // Check if platform parameter is passed correctly |
| 77 | platform := req.URL.Query().Get("platform") |
| 78 | if platform != expectedPlatform { |
| 79 | return nil, fmt.Errorf("Expected platform '%s', got '%s'", expectedPlatform, platform) |
| 80 | } |
| 81 | |
| 82 | return mockJSONResponse(http.StatusOK, nil, image.InspectResponse{ |
| 83 | ID: "image_id", |
| 84 | Architecture: "arm64", |
| 85 | Os: "linux", |
| 86 | })(req) |
| 87 | })) |
| 88 | assert.NilError(t, err) |
| 89 | |
| 90 | imageInspect, err := client.ImageInspect(t.Context(), "image_id", ImageInspectWithPlatform(requestedPlatform)) |
| 91 | assert.NilError(t, err) |
| 92 | assert.Check(t, is.Equal(imageInspect.ID, "image_id")) |
| 93 | assert.Check(t, is.Equal(imageInspect.Architecture, "arm64")) |
| 94 | assert.Check(t, is.Equal(imageInspect.Os, "linux")) |
| 95 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…