From 510c35a4f35489e03d5ce1b12cef6b525681f72c Mon Sep 17 00:00:00 2001 From: Saylor Berman Date: Mon, 14 Oct 2024 20:45:27 +0300 Subject: [PATCH] Fix failing unit test (#2685) Problem: Intermittently one of our unit tests was failing. Solution: My hunch as to why it was failing is because of the parallel nature would occasionally cause an object to be in the wrong state for a specific test. So that object is now being defined for every test instead of globally. --- internal/mode/static/config_updater_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/mode/static/config_updater_test.go b/internal/mode/static/config_updater_test.go index c0830124d0..94807253b2 100644 --- a/internal/mode/static/config_updater_test.go +++ b/internal/mode/static/config_updater_test.go @@ -34,7 +34,6 @@ func TestUpdateControlPlane(t *testing.T) { } logger := zap.New() - fakeEventRecorder := record.NewFakeRecorder(1) nsname := types.NamespacedName{Namespace: "test", Name: "test"} tests := []struct { @@ -82,6 +81,8 @@ func TestUpdateControlPlane(t *testing.T) { }, } + fakeEventRecorder := record.NewFakeRecorder(1) + err := updateControlPlane(test.nginxGateway, logger, fakeEventRecorder, nsname, fakeLogSetter) if test.expErrString != "" {