@@ -102,8 +102,8 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
102
102
pluginProjectAlreadyDefinedErr := "Some Projects are already defined in plugin.* If you want to override them, you should do it in the plugin scope."
103
103
newCmdErr := "Some Commands do not override any existing element.* They should be defined in the main body, as new elements, not in the overriding section"
104
104
newCmpErr := "Some Components do not override any existing element.* They should be defined in the main body, as new elements, not in the overriding section"
105
+ newProjectErr := "Some Projects do not override any existing element.* They should be defined in the main body, as new elements, not in the overriding section"
105
106
importCycleErr := "devfile has an cycle in references: main devfile -> .*"
106
- overrideInvalidErr := fmt .Sprintf (".*\n .*%s\n .*%s" , newCmdErr , newCmpErr )
107
107
108
108
type args struct {
109
109
devFileObj DevfileObj
@@ -115,7 +115,7 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
115
115
pluginDevfile DevfileObj
116
116
pluginOverride v1.PluginOverrides
117
117
wantDevFile DevfileObj
118
- wantErr * string
118
+ wantErr [] string
119
119
testRecursiveReference bool
120
120
}{
121
121
{
@@ -444,6 +444,12 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
444
444
},
445
445
},
446
446
},
447
+ Projects : []v1.ProjectParentOverride {
448
+ {
449
+ ClonePath : "/projects" ,
450
+ Name : "nodejs-starter" ,
451
+ },
452
+ },
447
453
},
448
454
},
449
455
},
@@ -461,6 +467,7 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
461
467
DevWorkspaceTemplateSpecContent : v1.DevWorkspaceTemplateSpecContent {
462
468
Commands : []v1.Command {},
463
469
Components : []v1.Component {},
470
+ Projects : []v1.Project {},
464
471
},
465
472
},
466
473
},
@@ -469,7 +476,7 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
469
476
wantDevFile : DevfileObj {
470
477
Data : & v2.DevfileV2 {},
471
478
},
472
- wantErr : & overrideInvalidErr ,
479
+ wantErr : [] string { newCmpErr , newCmdErr , newProjectErr } ,
473
480
},
474
481
{
475
482
name : "error out if the same parent command is defined again in the local devfile" ,
@@ -522,7 +529,7 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
522
529
wantDevFile : DevfileObj {
523
530
Data : & v2.DevfileV2 {},
524
531
},
525
- wantErr : & parentCmdAlreadyDefinedErr ,
532
+ wantErr : [] string { parentCmdAlreadyDefinedErr } ,
526
533
},
527
534
{
528
535
name : "error out if the same parent component is defined again in the local devfile" ,
@@ -579,7 +586,7 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
579
586
wantDevFile : DevfileObj {
580
587
Data : & v2.DevfileV2 {},
581
588
},
582
- wantErr : & parentCmpAlreadyDefinedErr ,
589
+ wantErr : [] string { parentCmpAlreadyDefinedErr } ,
583
590
},
584
591
{
585
592
name : "should not have error if the same event is defined again in the local devfile" ,
@@ -699,7 +706,7 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
699
706
wantDevFile : DevfileObj {
700
707
Data : & v2.DevfileV2 {},
701
708
},
702
- wantErr : & parentProjectAlreadyDefinedErr ,
709
+ wantErr : [] string { parentProjectAlreadyDefinedErr } ,
703
710
},
704
711
{
705
712
name : "it should merge the plugin's uri data and add the local devfile's data" ,
@@ -1143,7 +1150,7 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
1143
1150
wantDevFile : DevfileObj {
1144
1151
Data : & v2.DevfileV2 {},
1145
1152
},
1146
- wantErr : & newCmdErr ,
1153
+ wantErr : [] string { newCmdErr } ,
1147
1154
},
1148
1155
{
1149
1156
name : "error out if the same plugin command is defined again in the local devfile" ,
@@ -1196,7 +1203,7 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
1196
1203
wantDevFile : DevfileObj {
1197
1204
Data : & v2.DevfileV2 {},
1198
1205
},
1199
- wantErr : & pluginCmdAlreadyDefinedErr ,
1206
+ wantErr : [] string { pluginCmdAlreadyDefinedErr } ,
1200
1207
},
1201
1208
{
1202
1209
name : "error out if the same plugin component is defined again in the local devfile" ,
@@ -1253,7 +1260,7 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
1253
1260
wantDevFile : DevfileObj {
1254
1261
Data : & v2.DevfileV2 {},
1255
1262
},
1256
- wantErr : & pluginCmpAlreadyDefinedErr ,
1263
+ wantErr : [] string { pluginCmpAlreadyDefinedErr } ,
1257
1264
},
1258
1265
{
1259
1266
name : "error out if the plugin project is defined again in the local devfile" ,
@@ -1316,7 +1323,7 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
1316
1323
wantDevFile : DevfileObj {
1317
1324
Data : & v2.DevfileV2 {},
1318
1325
},
1319
- wantErr : & pluginProjectAlreadyDefinedErr ,
1326
+ wantErr : [] string { pluginProjectAlreadyDefinedErr } ,
1320
1327
},
1321
1328
{
1322
1329
name : "error out if the same project is defined in the both plugin devfile and parent" ,
@@ -1407,7 +1414,7 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
1407
1414
wantDevFile : DevfileObj {
1408
1415
Data : & v2.DevfileV2 {},
1409
1416
},
1410
- wantErr : & pluginProjectAlreadyDefinedErr ,
1417
+ wantErr : [] string { pluginProjectAlreadyDefinedErr } ,
1411
1418
},
1412
1419
{
1413
1420
name : "error out if the same command is defined in both plugin devfile and parent devfile" ,
@@ -1483,7 +1490,7 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
1483
1490
wantDevFile : DevfileObj {
1484
1491
Data : & v2.DevfileV2 {},
1485
1492
},
1486
- wantErr : & pluginCmdAlreadyDefinedErr ,
1493
+ wantErr : [] string { pluginCmdAlreadyDefinedErr } ,
1487
1494
},
1488
1495
{
1489
1496
name : "error out if the same component is defined in both plugin devfile and parent devfile" ,
@@ -1565,7 +1572,7 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
1565
1572
wantDevFile : DevfileObj {
1566
1573
Data : & v2.DevfileV2 {},
1567
1574
},
1568
- wantErr : & pluginCmpAlreadyDefinedErr ,
1575
+ wantErr : [] string { pluginCmpAlreadyDefinedErr } ,
1569
1576
},
1570
1577
{
1571
1578
name : "it should override the requested parent's data and plugin's data, and add the local devfile's data" ,
@@ -1881,7 +1888,7 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
1881
1888
wantDevFile : DevfileObj {
1882
1889
Data : & v2.DevfileV2 {},
1883
1890
},
1884
- wantErr : & pluginCmpAlreadyDefinedErr ,
1891
+ wantErr : [] string { pluginCmpAlreadyDefinedErr } ,
1885
1892
},
1886
1893
{
1887
1894
name : "it should override with no errors if the plugin component is defined with a different component type in the plugin override" ,
@@ -2011,7 +2018,7 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
2011
2018
wantDevFile : DevfileObj {
2012
2019
Data : & v2.DevfileV2 {},
2013
2020
},
2014
- wantErr : & parentCmpAlreadyDefinedErr ,
2021
+ wantErr : [] string { parentCmpAlreadyDefinedErr } ,
2015
2022
},
2016
2023
{
2017
2024
name : "it should override with no errors if the parent component is defined with a different component type in the parent override" ,
@@ -2136,7 +2143,7 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
2136
2143
wantDevFile : DevfileObj {
2137
2144
Data : & v2.DevfileV2 {},
2138
2145
},
2139
- wantErr : & importCycleErr ,
2146
+ wantErr : [] string { importCycleErr } ,
2140
2147
testRecursiveReference : true ,
2141
2148
},
2142
2149
}
@@ -2228,7 +2235,9 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
2228
2235
} else if err == nil && ! reflect .DeepEqual (tt .args .devFileObj .Data , tt .wantDevFile .Data ) {
2229
2236
t .Errorf ("Test_parseParentAndPluginFromURI() error: wanted: %v, got: %v, difference at %v" , tt .wantDevFile .Data , tt .args .devFileObj .Data , pretty .Compare (tt .args .devFileObj .Data , tt .wantDevFile .Data ))
2230
2237
} else if err != nil {
2231
- assert .Regexp (t , * tt .wantErr , err .Error (), "Test_parseParentAndPluginFromURI(): Error message should match" )
2238
+ for _ , wantErr := range tt .wantErr {
2239
+ assert .Regexp (t , wantErr , err .Error (), "Test_parseParentAndPluginFromURI(): Error message should match" )
2240
+ }
2232
2241
}
2233
2242
})
2234
2243
}
@@ -3399,7 +3408,7 @@ func Test_parseFromRegistry(t *testing.T) {
3399
3408
invalidURLErr := "the provided registryURL: .* is not a valid URL"
3400
3409
URLNotFoundErr := "failed to retrieve .*, 404: Not Found"
3401
3410
missingRegistryURLErr := "failed to fetch from registry, registry URL is not provided"
3402
- invalidRegistryURLErr := "Get .* dial tcp: lookup http: no such host "
3411
+ invalidRegistryURLErr := "Get .* dial tcp: lookup http: .* "
3403
3412
3404
3413
testServer := httptest .NewUnstartedServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
3405
3414
var data []byte
0 commit comments