@@ -3633,6 +3633,46 @@ func TestReconcile_HTTPRouteExposure(t *testing.T) {
36333633 }
36343634}
36353635
3636+ func TestReconcile_HTTPRouteExposure_RequiresParentRefs (t * testing.T ) {
3637+ ensureGatewaySchemeRegistered (t )
3638+ ctx := context .Background ()
3639+ ensureHTTPRouteCRDInstalled (t )
3640+
3641+ cp := & coderv1alpha1.CoderControlPlane {
3642+ ObjectMeta : metav1.ObjectMeta {Name : "test-httproute-parentrefs-required" , Namespace : "default" },
3643+ Spec : coderv1alpha1.CoderControlPlaneSpec {
3644+ Image : "test-httproute:latest" ,
3645+ Expose : & coderv1alpha1.ExposeSpec {
3646+ Gateway : & coderv1alpha1.GatewayExposeSpec {
3647+ Host : "missing-parentrefs.gateway.example.test" ,
3648+ },
3649+ },
3650+ },
3651+ }
3652+ if err := k8sClient .Create (ctx , cp ); err != nil {
3653+ t .Fatalf ("create control plane: %v" , err )
3654+ }
3655+ t .Cleanup (func () {
3656+ _ = k8sClient .Delete (ctx , cp )
3657+ })
3658+
3659+ r := & controller.CoderControlPlaneReconciler {Client : k8sClient , Scheme : scheme }
3660+ namespacedName := types.NamespacedName {Name : cp .Name , Namespace : cp .Namespace }
3661+ _ , err := r .Reconcile (ctx , ctrl.Request {NamespacedName : namespacedName })
3662+ if err == nil {
3663+ t .Fatal ("expected reconcile to fail when gateway parentRefs are missing" )
3664+ }
3665+ if ! strings .Contains (err .Error (), "gateway parentRefs must not be empty" ) {
3666+ t .Fatalf ("expected missing parentRefs assertion error, got: %v" , err )
3667+ }
3668+
3669+ httpRoute := & gatewayv1.HTTPRoute {}
3670+ err = k8sClient .Get (ctx , namespacedName , httpRoute )
3671+ if ! apierrors .IsNotFound (err ) {
3672+ t .Fatalf ("expected httproute to be absent when parentRefs are missing, got: %v" , err )
3673+ }
3674+ }
3675+
36363676func TestReconcile_HTTPRouteExposure_CRDMissingIsGraceful (t * testing.T ) {
36373677 ensureGatewaySchemeRegistered (t )
36383678 ctx := context .Background ()
@@ -3647,6 +3687,9 @@ func TestReconcile_HTTPRouteExposure_CRDMissingIsGraceful(t *testing.T) {
36473687 Expose : & coderv1alpha1.ExposeSpec {
36483688 Gateway : & coderv1alpha1.GatewayExposeSpec {
36493689 Host : "missing-crd.gateway.example.test" ,
3690+ ParentRefs : []coderv1alpha1.GatewayParentRef {{
3691+ Name : "missing-crd-gateway" ,
3692+ }},
36503693 },
36513694 },
36523695 },
0 commit comments