@@ -2356,22 +2356,42 @@ func (s *testNGFLogSink) WithName(_ string) logr.LogSink {
2356
2356
2357
2357
// createPolicyWithExistingGatewayStatus creates a fake policy with a gateway in its status ancestors.
2358
2358
func createPolicyWithExistingGatewayStatus (gatewayNsName types.NamespacedName , controllerName string ) policies.Policy {
2359
- fakePolicy := & policiesfakes.FakePolicy {
2359
+ ancestors := []v1alpha2.PolicyAncestorStatus {
2360
+ {
2361
+ ControllerName : v1 .GatewayController (controllerName ),
2362
+ AncestorRef : v1.ParentReference {
2363
+ Group : helpers.GetPointer [v1.Group ](v1 .GroupName ),
2364
+ Kind : helpers.GetPointer [v1.Kind ](kinds .Gateway ),
2365
+ Namespace : (* v1 .Namespace )(& gatewayNsName .Namespace ),
2366
+ Name : v1 .ObjectName (gatewayNsName .Name ),
2367
+ },
2368
+ },
2369
+ }
2370
+ return createFakePolicyWithAncestors ("test-policy" , "test" , ancestors )
2371
+ }
2372
+
2373
+ // createFakePolicy creates a basic fake policy with common defaults.
2374
+ func createFakePolicy (name , namespace string ) * policiesfakes.FakePolicy {
2375
+ return & policiesfakes.FakePolicy {
2376
+ GetNameStub : func () string { return name },
2377
+ GetNamespaceStub : func () string { return namespace },
2360
2378
GetPolicyStatusStub : func () v1alpha2.PolicyStatus {
2361
- return v1alpha2.PolicyStatus {
2362
- Ancestors : []v1alpha2.PolicyAncestorStatus {
2363
- {
2364
- ControllerName : v1 .GatewayController (controllerName ),
2365
- AncestorRef : v1.ParentReference {
2366
- Group : helpers.GetPointer [v1.Group ](v1 .GroupName ),
2367
- Kind : helpers.GetPointer [v1.Kind ](kinds .Gateway ),
2368
- Namespace : (* v1 .Namespace )(& gatewayNsName .Namespace ),
2369
- Name : v1 .ObjectName (gatewayNsName .Name ),
2370
- },
2371
- },
2372
- },
2373
- }
2379
+ return v1alpha2.PolicyStatus {}
2380
+ },
2381
+ GetTargetRefsStub : func () []v1alpha2.LocalPolicyTargetReference {
2382
+ return []v1alpha2.LocalPolicyTargetReference {}
2374
2383
},
2375
2384
}
2376
- return fakePolicy
2385
+ }
2386
+
2387
+ // createFakePolicyWithAncestors creates a fake policy with specific ancestors.
2388
+ func createFakePolicyWithAncestors (
2389
+ name , namespace string ,
2390
+ ancestors []v1alpha2.PolicyAncestorStatus ,
2391
+ ) * policiesfakes.FakePolicy {
2392
+ policy := createFakePolicy (name , namespace )
2393
+ policy .GetPolicyStatusStub = func () v1alpha2.PolicyStatus {
2394
+ return v1alpha2.PolicyStatus {Ancestors : ancestors }
2395
+ }
2396
+ return policy
2377
2397
}
0 commit comments