Skip to content

Commit 2061227

Browse files
authored
Merge pull request #4949 from hs0210/work
Add unit test for func in remotes/docker/pusher.go
2 parents 86a7db4 + 1d26595 commit 2061227

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

remotes/docker/pusher_test.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
Copyright The containerd Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package docker
18+
19+
import (
20+
"reflect"
21+
"testing"
22+
23+
digest "github.com/opencontainers/go-digest"
24+
)
25+
26+
func TestGetManifestPath(t *testing.T) {
27+
for _, tc := range []struct {
28+
object string
29+
dgst digest.Digest
30+
expected []string
31+
}{
32+
{
33+
object: "foo",
34+
dgst: "bar",
35+
expected: []string{"manifests", "foo"},
36+
},
37+
{
38+
object: "foo@bar",
39+
dgst: "bar",
40+
expected: []string{"manifests", "foo"},
41+
},
42+
{
43+
object: "foo@bar",
44+
dgst: "foobar",
45+
expected: []string{"manifests", "foobar"},
46+
},
47+
} {
48+
if got := getManifestPath(tc.object, tc.dgst); !reflect.DeepEqual(got, tc.expected) {
49+
t.Fatalf("expected %v, but got %v", tc.expected, got)
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)