@@ -674,9 +674,9 @@ func TestAddGatewaysForBackendTLSPoliciesAncestorLimit(t *testing.T) {
674
674
675
675
// Create a test logger that captures log output
676
676
var logBuf bytes.Buffer
677
- testLogger := logr .New (& testLogSink {buffer : & logBuf })
677
+ testLogger := logr .New (& testNGFLogSink {buffer : & logBuf })
678
678
679
- // Create BackendTLSPolicy with 16 ancestors (full)
679
+ // Helper function to create ancestor references
680
680
getAncestorRef := func (ctlrName , parentName string ) v1alpha2.PolicyAncestorStatus {
681
681
return v1alpha2.PolicyAncestorStatus {
682
682
ControllerName : gatewayv1 .GatewayController (ctlrName ),
@@ -793,7 +793,7 @@ func TestAddGatewaysForBackendTLSPoliciesAncestorLimit(t *testing.T) {
793
793
g .Expect (condition .Type ).To (Equal (string (v1alpha2 .PolicyConditionAccepted )))
794
794
g .Expect (condition .Status ).To (Equal (metav1 .ConditionFalse ))
795
795
g .Expect (condition .Reason ).To (Equal (string (conditions .PolicyReasonAncestorLimitReached )))
796
- g .Expect (condition .Message ).To (ContainSubstring ("ancestor status list has reached the maximum size of 16 " ))
796
+ g .Expect (condition .Message ).To (ContainSubstring ("ancestor status list has reached the maximum size" ))
797
797
798
798
// Verify that gateway2 did not receive any conditions (normal case)
799
799
gateway2 := gateways [types.NamespacedName {Namespace : "test" , Name : "gateway2" }]
@@ -808,47 +808,3 @@ func TestAddGatewaysForBackendTLSPoliciesAncestorLimit(t *testing.T) {
808
808
g .Expect (logOutput ).To (ContainSubstring ("policyKind=BackendTLSPolicy" ))
809
809
g .Expect (logOutput ).To (ContainSubstring ("ancestor=test/gateway1" ))
810
810
}
811
-
812
- // testLogSink implements logr.LogSink for testing.
813
- type testLogSink struct {
814
- buffer * bytes.Buffer
815
- }
816
-
817
- func (s * testLogSink ) Init (_ logr.RuntimeInfo ) {}
818
-
819
- func (s * testLogSink ) Enabled (_ int ) bool {
820
- return true
821
- }
822
-
823
- func (s * testLogSink ) Info (_ int , msg string , keysAndValues ... interface {}) {
824
- s .buffer .WriteString (msg )
825
- for i := 0 ; i < len (keysAndValues ); i += 2 {
826
- if i + 1 < len (keysAndValues ) {
827
- s .buffer .WriteString (" " )
828
- if key , ok := keysAndValues [i ].(string ); ok {
829
- s .buffer .WriteString (key )
830
- }
831
- s .buffer .WriteString ("=" )
832
- if value , ok := keysAndValues [i + 1 ].(string ); ok {
833
- s .buffer .WriteString (value )
834
- }
835
- }
836
- }
837
- s .buffer .WriteString ("\n " )
838
- }
839
-
840
- func (s * testLogSink ) Error (err error , msg string , _ ... interface {}) {
841
- s .buffer .WriteString ("ERROR: " )
842
- s .buffer .WriteString (msg )
843
- s .buffer .WriteString (" error=" )
844
- s .buffer .WriteString (err .Error ())
845
- s .buffer .WriteString ("\n " )
846
- }
847
-
848
- func (s * testLogSink ) WithValues (_ ... interface {}) logr.LogSink {
849
- return s
850
- }
851
-
852
- func (s * testLogSink ) WithName (_ string ) logr.LogSink {
853
- return s
854
- }
0 commit comments