@@ -2188,7 +2188,7 @@ func Test_parseParentAndPluginFromURI(t *testing.T) {
2188
2188
}
2189
2189
}
2190
2190
2191
- func Test_parseParentAndPlugin_RecursivelyReference_withMultipleURI (t * testing.T ) {
2191
+ func Test_parseParentAndPlugin_RecursivelyReference (t * testing.T ) {
2192
2192
const uri1 = "127.0.0.1:8080"
2193
2193
const uri2 = "127.0.0.1:9090"
2194
2194
const uri3 = "127.0.0.1:8090"
@@ -2266,26 +2266,20 @@ func Test_parseParentAndPlugin_RecursivelyReference_withMultipleURI(t *testing.T
2266
2266
SchemaVersion : schemaV200 ,
2267
2267
},
2268
2268
DevWorkspaceTemplateSpec : v1.DevWorkspaceTemplateSpec {
2269
- DevWorkspaceTemplateSpecContent : v1.DevWorkspaceTemplateSpecContent {
2270
- Components : []v1.Component {
2271
- {
2272
- Name : "plugin" ,
2273
- ComponentUnion : v1.ComponentUnion {
2274
- Plugin : & v1.PluginComponent {
2275
- ImportReference : v1.ImportReference {
2276
- ImportReferenceUnion : v1.ImportReferenceUnion {
2277
- Uri : httpPrefix + uri3 ,
2278
- },
2279
- },
2280
- },
2281
- },
2269
+ Parent : & v1.Parent {
2270
+ ImportReference : v1.ImportReference {
2271
+ ImportReferenceUnion : v1.ImportReferenceUnion {
2272
+ Id : "nodejs" ,
2282
2273
},
2274
+ RegistryUrl : httpPrefix + uri3 ,
2283
2275
},
2284
2276
},
2277
+ DevWorkspaceTemplateSpecContent : v1.DevWorkspaceTemplateSpecContent {},
2285
2278
},
2286
2279
},
2287
2280
},
2288
2281
}
2282
+
2289
2283
parentDevfile3 := DevfileObj {
2290
2284
Ctx : devfileCtx .NewDevfileCtx (OutputDevfileYamlPath ),
2291
2285
Data : & v2.DevfileV2 {
@@ -2369,7 +2363,13 @@ func Test_parseParentAndPlugin_RecursivelyReference_withMultipleURI(t *testing.T
2369
2363
defer testServer2 .Close ()
2370
2364
2371
2365
testServer3 := httptest .NewUnstartedServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
2372
- data , err := yaml .Marshal (parentDevfile3 .Data )
2366
+ var data []byte
2367
+ if strings .Contains (r .URL .Path , "/devfiles/nodejs" ) {
2368
+ data , err = yaml .Marshal (parentDevfile3 .Data )
2369
+ } else {
2370
+ w .WriteHeader (http .StatusNotFound )
2371
+ return
2372
+ }
2373
2373
if err != nil {
2374
2374
t .Errorf ("unexpected error: %v" , err )
2375
2375
}
@@ -2391,14 +2391,15 @@ func Test_parseParentAndPlugin_RecursivelyReference_withMultipleURI(t *testing.T
2391
2391
2392
2392
testServer3 .Start ()
2393
2393
defer testServer3 .Close ()
2394
- t .Run ("it should error out if URI is recursively referenced with multiple references" , func (t * testing.T ) {
2394
+
2395
+ t .Run ("it should error out if import reference has a cycle" , func (t * testing.T ) {
2395
2396
err := parseParentAndPlugin (devFileObj , & resolutionContextTree {}, resolverTools {})
2396
- // devfile has an cycle in references: main devfile -> uri: http://127.0.0.1:8080 -> uri: http://127.0.0.1:9090 -> uri : http://127.0.0.1:8090 -> uri: http://127.0.0.1:8080
2397
- expectedErr := fmt .Sprintf ("devfile has an cycle in references: main devfile -> uri: %s%s -> uri: %s%s -> uri : %s%s -> uri: %s%s" , httpPrefix , uri1 ,
2397
+ // devfile has a cycle in references: main devfile -> uri: http://127.0.0.1:8080 -> uri: http://127.0.0.1:9090 -> id: nodejs, registryURL : http://127.0.0.1:8090 -> uri: http://127.0.0.1:8080
2398
+ expectedErr := fmt .Sprintf ("devfile has an cycle in references: main devfile -> uri: %s%s -> uri: %s%s -> id: nodejs, registryURL : %s%s -> uri: %s%s" , httpPrefix , uri1 ,
2398
2399
httpPrefix , uri2 , httpPrefix , uri3 , httpPrefix , uri1 )
2399
2400
// Unexpected error
2400
2401
if err == nil || ! reflect .DeepEqual (expectedErr , err .Error ()) {
2401
- t .Errorf ("Test_parseParentAndPlugin_RecursivelyReference_withMultipleURI() unexpected error = %v" , err )
2402
+ t .Errorf ("Test_parseParentAndPlugin_RecursivelyReference unexpected error = %v" , err )
2402
2403
return
2403
2404
}
2404
2405
0 commit comments