forked from aquasecurity/fanal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoci_test.go
57 lines (54 loc) · 1.26 KB
/
oci_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
package image
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestTryOCI(t *testing.T) {
tests := []struct {
name string
ociImagePath string
wantErr string
}{
{
name: "correct path to index without tag",
ociImagePath: "testdata/multi",
wantErr: "",
},
{
name: "correct path to index with correct tag",
ociImagePath: "testdata/multi:tg11",
wantErr: "",
},
{
name: "correct path to index with incorrect tag",
ociImagePath: "testdata/multi:tg12",
wantErr: "invalid OCI image tag",
},
{
name: "correct path to manifest without tag",
ociImagePath: "testdata/single",
wantErr: "",
},
{
name: "correct path to manifest with correct tag",
ociImagePath: "testdata/single:3.14",
wantErr: "",
},
{
name: "correct path to manifest with incorrect tag",
ociImagePath: "testdata/single:3.11",
wantErr: "invalid OCI image tag",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
_, err := tryOCI(test.ociImagePath)
if test.wantErr != "" {
assert.NotNil(t, err)
assert.Contains(t, err.Error(), test.wantErr, err)
} else {
assert.NoError(t, err)
}
})
}
}