-
Notifications
You must be signed in to change notification settings - Fork 565
/
distribution_test.go
58 lines (53 loc) · 1.39 KB
/
distribution_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2017 go-dockerclient authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package docker
import (
"encoding/json"
"net/http"
"reflect"
"testing"
"github.com/docker/docker/api/types/registry"
)
func TestInspectDistribution(t *testing.T) {
t.Parallel()
jsonDistribution := `{
"Descriptor": {
"MediaType": "application/vnd.docker.distribution.manifest.v2+json",
"Digest": "sha256:c0537ff6a5218ef531ece93d4984efc99bbf3f7497c0a7726c88e2bb7584dc96",
"Size": 3987495,
"URLs": [
""
]
},
"Platforms": [
{
"Architecture": "amd64",
"OS": "linux",
"OSVersion": "",
"OSFeatures": [
""
],
"Variant": "",
"Features": [
""
]
}
]
}`
var expected registry.DistributionInspect
err := json.Unmarshal([]byte(jsonDistribution), &expected)
if err != nil {
t.Fatal(err)
}
fakeRT := &FakeRoundTripper{message: jsonDistribution, status: http.StatusOK}
client := newTestClient(fakeRT)
// image name/tag is not present in the reply, so it can be omitted for testing purposes
distributionInspect, err := client.InspectDistribution("")
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(*distributionInspect, expected) {
t.Errorf("InspectDistribution(%q): Expected %#v. Got %#v.", "", expected, distributionInspect)
}
}