@@ -37,102 +37,56 @@ func (tc vcsTestCase) Name() string {
37
37
38
38
func TestVCS (t * testing.T ) {
39
39
testCases := []vcsTestCase {
40
+ // {
41
+ // URL: "https://github.com/stefanprodan/podinfo",
42
+ // CheckoutTag: "6.7.0", // => 0b1481aa8ed0a6c34af84f779824a74200d5c1d6
43
+ // LoadPath: "kustomize",
44
+ // ExpectManifests: []string{"kustomization.yaml", "deployment.yaml", "hpa.yaml", "service.yaml"},
45
+ // ExpectImageTags: []string{"6.7.0"},
46
+ // ExpectRawTags: []string{"6.7.0"},
47
+ // },
48
+ // {
49
+ // URL: "https://github.com/stefanprodan/podinfo",
50
+ // CheckoutHash: "0b1481aa8ed0a6c34af84f779824a74200d5c1d6", // => 6.7.0
51
+ // Branch: "master",
52
+ // LoadPath: "kustomize",
53
+ // ExpectManifests: []string{"kustomization.yaml", "deployment.yaml", "hpa.yaml", "service.yaml"},
54
+ // ExpectImageTags: []string{"6.7.0"},
55
+ // ExpectRawTags: []string{"6.7.0"},
56
+ // },
40
57
{
41
- URL : "https://github.com/stefanprodan/podinfo" ,
42
- CheckoutTag : "6.7.0" , // => 0b1481aa8ed0a6c34af84f779824a74200d5c1d6
43
- LoadPath : "kustomize" ,
44
- ExpectManifests : []string {"kustomization.yaml" , "deployment.yaml" , "hpa.yaml" , "service.yaml" },
45
- ExpectImageTags : []string {"6.7.0" },
46
- ExpectRawTags : []string {"6.7.0" },
47
- },
48
- {
49
- URL : "https://github.com/stefanprodan/podinfo" ,
50
- CheckoutHash : "0b1481aa8ed0a6c34af84f779824a74200d5c1d6" , // => 6.7.0
51
- Branch : "master" ,
52
- LoadPath : "kustomize" ,
53
- ExpectManifests : []string {"kustomization.yaml" , "deployment.yaml" , "hpa.yaml" , "service.yaml" },
54
- ExpectImageTags : []string {"6.7.0" },
55
- ExpectRawTags : []string {"6.7.0" },
56
- },
57
- {
58
- URL : "https://github.com/stefanprodan/podinfo" ,
59
- CheckoutHash : "ba6f4ffd7cba98ea2ef52bee7c1bead8e1d6a7d3" , // pre-6.7.0
60
- Branch : "master" ,
61
- LoadPath : "kustomize" ,
58
+ URL : "https://github.com/errordeveloper/tape-git-testing" ,
59
+ CheckoutHash : "3cad1d255c1d83b5e523de64d34758609498d81b" ,
60
+ Branch : "main" ,
61
+ LoadPath : "" ,
62
62
ExpectManifests : []string {"kustomization.yaml" , "deployment.yaml" , "hpa.yaml" , "service.yaml" },
63
63
ExpectImageTags : nil ,
64
64
ExpectRawTags : nil ,
65
65
},
66
66
{
67
- URL : "https://github.com/stefanprodan/podinfo" ,
68
- CheckoutTag : "6.6.1" ,
69
- Branch : "master" ,
70
- LoadPath : "kustomize" ,
71
- ExpectManifests : []string {"kustomization.yaml" , "deployment.yaml" , "hpa.yaml" , "service.yaml" },
72
- ExpectImageTags : []string {"6.6.1" },
73
- ExpectRawTags : []string {"6.6.1" },
74
- },
75
- {
76
- URL : "https://github.com/stefanprodan/podinfo" ,
77
- CheckoutTag : "6.6.2" ,
78
- Branch : "master" ,
67
+ URL : "https://github.com/errordeveloper/tape-git-testing" ,
68
+ CheckoutTag : "0.0.1" ,
79
69
LoadPath : "" ,
80
- ExpectManifests : []string {"kustomize /kustomization.yaml" , "kustomize /deployment.yaml" , "kustomize /hpa.yaml" , "kustomize /service.yaml" },
81
- ExpectImageTags : []string {"6.6 .1" },
82
- ExpectRawTags : []string {"6.6.1 " },
70
+ ExpectManifests : []string {"podinfo /kustomization.yaml" , "podinfo /deployment.yaml" , "podinfo /hpa.yaml" , "podinfo /service.yaml" },
71
+ ExpectImageTags : []string {"v0.0 .1" },
72
+ ExpectRawTags : []string {"0.0.1" , "v0.0.1" , "podinfo/v6.6.3 " },
83
73
},
84
74
{
85
- URL : "https://github.com/fluxcd/pkg " ,
86
- CheckoutHash : "c647aea83012218c0353d3408b2237bb639578f3 " ,
87
- Branch : "master " ,
88
- LoadPath : "version" ,
89
- ExpectImageTags : nil ,
90
- ExpectRawTags : nil ,
75
+ URL : "https://github.com/errordeveloper/tape-git-testing " ,
76
+ CheckoutTag : "v0.0.2 " ,
77
+ LoadPath : "podinfo " ,
78
+ ExpectManifests : [] string { "kustomization.yaml" , "deployment.yaml" , "hpa.yaml" , "service.yaml" } ,
79
+ ExpectImageTags : [] string { "v0.0.2" } ,
80
+ ExpectRawTags : [] string { "0.0.2" , "v0.0.2" , "podinfo/v6.7.0" } ,
91
81
},
92
- // {
93
- // URL: "https://github.com/fluxcd/pkg",
94
- // CheckoutTag: "version/v0.4.0",
95
- // Branch: "master",
96
- // LoadPath: "version",
97
- // ExpectImageTags: nil, // TODO: should be 0.4.0
98
- // ExpectRawTags: []string{
99
- // "version/v0.4.0",
100
- // "testserver/v0.7.0",
101
- // "tar/v0.7.0",
102
- // "ssh/v0.13.0",
103
- // "ssa/v0.39.1",
104
- // "ssa/v0.39.0",
105
- // "sourceignore/v0.7.0",
106
- // "runtime/v0.47.1",
107
- // "runtime/v0.47.0",
108
- // "oci/v0.38.1",
109
- // "oci/v0.38.0",
110
- // "oci/v0.37.1",
111
- // "oci/v0.37.0",
112
- // "masktoken/v0.4.0",
113
- // "lockedfile/v0.3.0",
114
- // "kustomize/v1.11.0",
115
- // "http/transport/v0.3.0",
116
- // "http/fetch/v0.11.0",
117
- // "helmtestserver/v0.18.0",
118
- // "gittestserver/v0.12.0",
119
- // "git/v0.19.0",
120
- // "git/gogit/v0.19.0",
121
- // "envsubst/v1.1.0",
122
- // "cache/v0.0.1",
123
- // "apis/meta/v1.5.0",
124
- // "apis/kustomize/v1.5.0",
125
- // "apis/event/v0.9.0",
126
- // "apis/acl/v0.3.0",
127
- // },
128
- // },
129
82
}
130
83
131
84
repos := & repos {}
132
85
repos .init ()
133
86
defer repos .cleanup ()
134
87
135
- for _ , tc := range testCases {
88
+ for i := range testCases {
89
+ tc := testCases [i ]
136
90
t .Run (tc .Name (), makeVCSTest (repos , tc ))
137
91
}
138
92
}
@@ -158,7 +112,10 @@ func makeVCSTest(repos *repos, tc vcsTestCase) func(t *testing.T) {
158
112
scanner .WithProvinanceAttestor (attreg )
159
113
160
114
if tc .ExpectManifests != nil {
161
- g .Expect (loader .Paths ()).To (ConsistOf (tc .ExpectManifests ))
115
+ g .Expect (loader .Paths ()).To (HaveLen (len (tc .ExpectManifests )))
116
+ for _ , manifest := range tc .ExpectManifests {
117
+ g .Expect (loader .ContainsRelPath (manifest )).To (BeTrue ())
118
+ }
162
119
}
163
120
164
121
g .Expect (scanner .Scan (loader .RelPaths ())).To (Succeed ())
@@ -188,19 +145,22 @@ func makeVCSTest(repos *repos, tc vcsTestCase) func(t *testing.T) {
188
145
g .Expect (ok ).To (BeTrue ())
189
146
ref := groupSummary .Git .Reference
190
147
g .Expect (ref .Tags ).To (HaveLen (len (tc .ExpectRawTags )))
191
- for i , tag := range tc .ExpectRawTags {
192
- g .Expect (ref .Tags [i ].Name ).To (Equal (tag ))
148
+ imageTagNames := make ([]string , len (ref .Tags ))
149
+ for i , tag := range ref .Tags {
150
+ imageTagNames [i ] = tag .Name
193
151
}
152
+ g .Expect (imageTagNames ).To (ConsistOf (tc .ExpectRawTags ))
194
153
195
154
image , err := name .NewRepository ("podinfo" )
196
155
g .Expect (err ).NotTo (HaveOccurred ())
197
156
198
157
semVerTags := oci .SemVerTagsFromAttestations (ctx , image .Tag ("test.123456" ), statements ... )
199
-
200
158
g .Expect (semVerTags ).To (HaveLen (len (tc .ExpectImageTags )))
201
- for i , tag := range tc .ExpectImageTags {
202
- g .Expect (semVerTags [i ].TagStr ()).To (Equal (tag ))
159
+ semVerTagNames := make ([]string , len (semVerTags ))
160
+ for i , tag := range semVerTags {
161
+ semVerTagNames [i ] = tag .TagStr ()
203
162
}
163
+ g .Expect (semVerTagNames ).To (ConsistOf (tc .ExpectImageTags ))
204
164
}
205
165
}
206
166
0 commit comments