@@ -118,6 +118,17 @@ var expRouteBackendRef = RouteBackendRef{
118118 },
119119}
120120
121+ func createInferencePoolBackend (name , namespace string ) gatewayv1.BackendRef {
122+ return gatewayv1.BackendRef {
123+ BackendObjectReference : gatewayv1.BackendObjectReference {
124+ Group : helpers.GetPointer [gatewayv1.Group ](inferenceAPIGroup ),
125+ Kind : helpers.GetPointer [gatewayv1.Kind ](kinds .InferencePool ),
126+ Name : gatewayv1 .ObjectName (name ),
127+ Namespace : helpers .GetPointer (gatewayv1 .Namespace (namespace )),
128+ },
129+ }
130+ }
131+
121132func TestBuildHTTPRoutes (t * testing.T ) {
122133 t .Parallel ()
123134
@@ -383,28 +394,14 @@ func TestBuildHTTPRoute(t *testing.T) {
383394 hrInferencePool := createHTTPRoute ("hr" , gatewayNsName .Name , "example.com" , "/" )
384395 hrInferencePool .Spec .Rules [0 ].BackendRefs = []gatewayv1.HTTPBackendRef {
385396 {
386- BackendRef : gatewayv1.BackendRef {
387- BackendObjectReference : gatewayv1.BackendObjectReference {
388- Group : helpers.GetPointer [gatewayv1.Group ](inferenceAPIGroup ),
389- Kind : helpers.GetPointer [gatewayv1.Kind ](kinds .InferencePool ),
390- Name : "ipool" ,
391- Namespace : helpers .GetPointer (gatewayv1 .Namespace (gatewayNsName .Namespace )),
392- },
393- },
397+ BackendRef : createInferencePoolBackend ("ipool" , gatewayNsName .Namespace ),
394398 },
395399 }
396- // route with an inference pool backend
400+ // route with an inference pool backend that does not exist
397401 hrInferencePoolDoesNotExist := createHTTPRoute ("hr" , gatewayNsName .Name , "example.com" , "/" )
398402 hrInferencePoolDoesNotExist .Spec .Rules [0 ].BackendRefs = []gatewayv1.HTTPBackendRef {
399403 {
400- BackendRef : gatewayv1.BackendRef {
401- BackendObjectReference : gatewayv1.BackendObjectReference {
402- Group : helpers.GetPointer [gatewayv1.Group ](inferenceAPIGroup ),
403- Kind : helpers.GetPointer [gatewayv1.Kind ](kinds .InferencePool ),
404- Name : "ipool-does-not-exist" ,
405- Namespace : helpers .GetPointer (gatewayv1 .Namespace (gatewayNsName .Namespace )),
406- },
407- },
404+ BackendRef : createInferencePoolBackend ("ipool-does-not-exist" , gatewayNsName .Namespace ),
408405 },
409406 }
410407
@@ -1045,14 +1042,7 @@ func TestBuildHTTPRoute(t *testing.T) {
10451042 Matches : hrInferencePoolDoesNotExist .Spec .Rules [0 ].Matches ,
10461043 RouteBackendRefs : []RouteBackendRef {
10471044 {
1048- BackendRef : gatewayv1.BackendRef {
1049- BackendObjectReference : gatewayv1.BackendObjectReference {
1050- Group : helpers.GetPointer [gatewayv1.Group ](inferenceAPIGroup ),
1051- Kind : helpers.GetPointer [gatewayv1.Kind ](kinds .InferencePool ),
1052- Name : "ipool-does-not-exist" ,
1053- Namespace : helpers.GetPointer [gatewayv1.Namespace ]("test" ),
1054- },
1055- },
1045+ BackendRef : createInferencePoolBackend ("ipool-does-not-exist" , gatewayNsName .Namespace ),
10561046 },
10571047 },
10581048 },
0 commit comments