Skip to content

Commit

Permalink
fix: code review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
hessjcg committed Sep 21, 2023
1 parent 62217e0 commit 9a605df
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions internal/workload/podspec_updates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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,
Expand All @@ -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
}
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 9a605df

Please sign in to comment.