@@ -187,6 +187,25 @@ func TestComponentCreateValidatingWebhook(t *testing.T) {
187187 },
188188 },
189189 },
190+ {
191+ name : "component needs to have one source specified, new GitURL field" ,
192+ client : fakeClient ,
193+ err : appstudiov1alpha1 .MissingGitOrImageSource ,
194+ newComp : appstudiov1alpha1.Component {
195+ ObjectMeta : v1.ObjectMeta {
196+ Name : "test-component" ,
197+ },
198+ Spec : appstudiov1alpha1.ComponentSpec {
199+ ComponentName : "component1" ,
200+ Application : "application1" ,
201+ Source : appstudiov1alpha1.ComponentSource {
202+ ComponentSourceUnion : appstudiov1alpha1.ComponentSourceUnion {
203+ GitURL : "" ,
204+ },
205+ },
206+ },
207+ },
208+ },
190209 {
191210 name : "valid component with invalid git scheme src" ,
192211 client : fakeClient ,
@@ -209,8 +228,9 @@ func TestComponentCreateValidatingWebhook(t *testing.T) {
209228 },
210229 },
211230 {
212- name : "valid component with container image " ,
231+ name : "invalid component without git source " ,
213232 client : fakeClient ,
233+ err : appstudiov1alpha1 .MissingGitOrImageSource ,
214234 newComp : appstudiov1alpha1.Component {
215235 ObjectMeta : v1.ObjectMeta {
216236 Name : "test-component" ,
@@ -222,6 +242,44 @@ func TestComponentCreateValidatingWebhook(t *testing.T) {
222242 },
223243 },
224244 },
245+ {
246+ name : "valid component with git source" ,
247+ client : fakeClient ,
248+ newComp : appstudiov1alpha1.Component {
249+ ObjectMeta : v1.ObjectMeta {
250+ Name : "test-component" ,
251+ },
252+ Spec : appstudiov1alpha1.ComponentSpec {
253+ ComponentName : "component1" ,
254+ Application : "application1" ,
255+ Source : appstudiov1alpha1.ComponentSource {
256+ ComponentSourceUnion : appstudiov1alpha1.ComponentSourceUnion {
257+ GitSource : & appstudiov1alpha1.GitSource {
258+ URL : "http://link" ,
259+ },
260+ },
261+ },
262+ },
263+ },
264+ },
265+ {
266+ name : "valid component with git source, new GitURL field" ,
267+ client : fakeClient ,
268+ newComp : appstudiov1alpha1.Component {
269+ ObjectMeta : v1.ObjectMeta {
270+ Name : "test-component" ,
271+ },
272+ Spec : appstudiov1alpha1.ComponentSpec {
273+ ComponentName : "component1" ,
274+ Application : "application1" ,
275+ Source : appstudiov1alpha1.ComponentSource {
276+ ComponentSourceUnion : appstudiov1alpha1.ComponentSourceUnion {
277+ GitURL : "http://link" ,
278+ },
279+ },
280+ },
281+ },
282+ },
225283 {
226284 name : "validate succeeds but updating nudged component fails" ,
227285 client : fakeErrorClient ,
@@ -238,6 +296,13 @@ func TestComponentCreateValidatingWebhook(t *testing.T) {
238296 BuildNudgesRef : []string {
239297 "alternating-error-comp" ,
240298 },
299+ Source : appstudiov1alpha1.ComponentSource {
300+ ComponentSourceUnion : appstudiov1alpha1.ComponentSourceUnion {
301+ GitSource : & appstudiov1alpha1.GitSource {
302+ URL : "http://link" ,
303+ },
304+ },
305+ },
241306 },
242307 },
243308 },
@@ -290,27 +355,6 @@ func TestComponentUpdateValidatingWebhook(t *testing.T) {
290355 updateComp appstudiov1alpha1.Component
291356 err string
292357 }{
293- {
294- name : "component name cannot be changed" ,
295- client : fakeClient ,
296- err : fmt .Errorf (appstudiov1alpha1 .ComponentNameUpdateError , "component1" ).Error (),
297- updateComp : appstudiov1alpha1.Component {
298- Spec : appstudiov1alpha1.ComponentSpec {
299- ComponentName : "component1" ,
300- },
301- },
302- },
303- {
304- name : "application name cannot be changed" ,
305- client : fakeClient ,
306- err : fmt .Errorf (appstudiov1alpha1 .ApplicationNameUpdateError , "application1" ).Error (),
307- updateComp : appstudiov1alpha1.Component {
308- Spec : appstudiov1alpha1.ComponentSpec {
309- ComponentName : "component" ,
310- Application : "application1" ,
311- },
312- },
313- },
314358 {
315359 name : "git src url cannot be changed" ,
316360 client : fakeClient ,
0 commit comments