From 9a605df147eafd5542e3938ea85198a66ee513ef Mon Sep 17 00:00:00 2001 From: Jonathan Hess <hessjc@google.com> Date: Thu, 21 Sep 2023 09:20:20 -0600 Subject: [PATCH] fix: code review comments. --- internal/workload/podspec_updates_test.go | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/internal/workload/podspec_updates_test.go b/internal/workload/podspec_updates_test.go index 3c20588e..bc90e8e0 100644 --- a/internal/workload/podspec_updates_test.go +++ b/internal/workload/podspec_updates_test.go @@ -917,9 +917,7 @@ func TestPodTemplateAnnotations(t *testing.T) { func TestTelemetryAddsTelemetryContainerPort(t *testing.T) { - var ( - u = workload.NewUpdater("cloud-sql-proxy-operator/dev", workload.DefaultProxyImage) - ) + var u = workload.NewUpdater("cloud-sql-proxy-operator/dev", workload.DefaultProxyImage) // Create a pod wl := podWorkload() @@ -932,10 +930,6 @@ func TestTelemetryAddsTelemetryContainerPort(t *testing.T) { simpleAuthProxy("instance2", "project:server2:db2"), simpleAuthProxy("instance3", "project:server3:db3")} - csqls[0].ObjectMeta.Generation = 1 - csqls[1].ObjectMeta.Generation = 2 - csqls[2].ObjectMeta.Generation = 3 - var wantPorts = map[string]int32{ workload.ContainerName(csqls[0]): workload.DefaultHealthCheckPort, workload.ContainerName(csqls[1]): workload.DefaultHealthCheckPort + 1, @@ -949,16 +943,16 @@ func TestTelemetryAddsTelemetryContainerPort(t *testing.T) { } // test that containerPort values were set properly - for name, port := range wantPorts { - found := false + for name, wantPort := range wantPorts { + var found bool for _, c := range wl.PodSpec().Containers { if c.Name == name { found = true if len(c.Ports) == 0 { - t.Fatalf("want container port for conatiner %s at port %d, got no containerPort", name, port) + t.Fatalf("want container wantPort for conatiner %s at wantPort %d, got no containerPort", name, wantPort) } - if got := c.Ports[0].ContainerPort; got != port { - t.Errorf("want container port for conatiner %s at port %d, got port = %d ", name, port, got) + if got := c.Ports[0].ContainerPort; got != wantPort { + t.Errorf("want container wantPort for conatiner %s at wantPort %d, got wantPort = %d ", name, wantPort, got) } continue } @@ -987,10 +981,6 @@ func TestQuitURLEnvVar(t *testing.T) { simpleAuthProxy("instance2", "project:server2:db2"), simpleAuthProxy("instance3", "project:server3:db3")} - csqls[0].ObjectMeta.Generation = 1 - csqls[1].ObjectMeta.Generation = 2 - csqls[2].ObjectMeta.Generation = 3 - var wantQuitURLSEnv = strings.Join( []string{ fmt.Sprintf("http://localhost:%d/quitquitquit", workload.DefaultAdminPort),