From 476647193f946ca2daa14ccc221412de0d7f6d93 Mon Sep 17 00:00:00 2001 From: Yu-Lin Chen Date: Fri, 12 Jul 2024 06:31:50 +0000 Subject: [PATCH] fix lint --- pkg/admission/admission_controller_test.go | 30 +++++++++++----------- pkg/common/utils/utils_test.go | 1 + 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/pkg/admission/admission_controller_test.go b/pkg/admission/admission_controller_test.go index 7cefee4b1..10c287db6 100644 --- a/pkg/admission/admission_controller_test.go +++ b/pkg/admission/admission_controller_test.go @@ -114,9 +114,9 @@ func TestUpdateLabels(t *testing.T) { patch = c.updateLabels("default", pod, patch) assert.Equal(t, len(patch), 1) - assert.Equal(t, patch[0].Op, "add") - assert.Equal(t, patch[0].Path, "/metadata/labels") - if updatedMap, ok := patch[0].Value.(map[string]string); ok { + assert.Equal(t, patch[0].Op, "add") //nolint:gosec + assert.Equal(t, patch[0].Path, "/metadata/labels") //nolint:gosec + if updatedMap, ok := patch[0].Value.(map[string]string); ok { //nolint:gosec assert.Equal(t, len(updatedMap), 3) assert.Equal(t, updatedMap["random"], "random") assert.Equal(t, updatedMap[constants.CanonicalLabelApplicationID], "app-0001") @@ -151,9 +151,9 @@ func TestUpdateLabels(t *testing.T) { patch = c.updateLabels("default", pod, patch) assert.Equal(t, len(patch), 1) - assert.Equal(t, patch[0].Op, "add") - assert.Equal(t, patch[0].Path, "/metadata/labels") - if updatedMap, ok := patch[0].Value.(map[string]string); ok { + assert.Equal(t, patch[0].Op, "add") //nolint:gosec + assert.Equal(t, patch[0].Path, "/metadata/labels") //nolint:gosec + if updatedMap, ok := patch[0].Value.(map[string]string); ok { //nolint:gosec assert.Equal(t, len(updatedMap), 5) assert.Equal(t, updatedMap["random"], "random") assert.Equal(t, updatedMap[constants.CanonicalLabelQueueName], "root.abc") @@ -185,9 +185,9 @@ func TestUpdateLabels(t *testing.T) { patch = c.updateLabels("default", pod, patch) assert.Equal(t, len(patch), 1) - assert.Equal(t, patch[0].Op, "add") - assert.Equal(t, patch[0].Path, "/metadata/labels") - if updatedMap, ok := patch[0].Value.(map[string]string); ok { + assert.Equal(t, patch[0].Op, "add") //nolint:gosec + assert.Equal(t, patch[0].Path, "/metadata/labels") //nolint:gosec + if updatedMap, ok := patch[0].Value.(map[string]string); ok { //nolint:gosec assert.Equal(t, len(updatedMap), 2) assert.Equal(t, strings.HasPrefix(updatedMap[constants.CanonicalLabelApplicationID], constants.AutoGenAppPrefix), true) assert.Equal(t, strings.HasPrefix(updatedMap[constants.LabelApplicationID], constants.AutoGenAppPrefix), true) @@ -213,9 +213,9 @@ func TestUpdateLabels(t *testing.T) { patch = c.updateLabels("default", pod, patch) assert.Equal(t, len(patch), 1) - assert.Equal(t, patch[0].Op, "add") - assert.Equal(t, patch[0].Path, "/metadata/labels") - if updatedMap, ok := patch[0].Value.(map[string]string); ok { + assert.Equal(t, patch[0].Op, "add") //nolint:gosec + assert.Equal(t, patch[0].Path, "/metadata/labels") //nolint:gosec + if updatedMap, ok := patch[0].Value.(map[string]string); ok { //nolint:gosec assert.Equal(t, len(updatedMap), 2) assert.Equal(t, strings.HasPrefix(updatedMap[constants.CanonicalLabelApplicationID], constants.AutoGenAppPrefix), true) assert.Equal(t, strings.HasPrefix(updatedMap[constants.LabelApplicationID], constants.AutoGenAppPrefix), true) @@ -239,9 +239,9 @@ func TestUpdateLabels(t *testing.T) { patch = c.updateLabels("default", pod, patch) assert.Equal(t, len(patch), 1) - assert.Equal(t, patch[0].Op, "add") - assert.Equal(t, patch[0].Path, "/metadata/labels") - if updatedMap, ok := patch[0].Value.(map[string]string); ok { + assert.Equal(t, patch[0].Op, "add") //nolint:gosec + assert.Equal(t, patch[0].Path, "/metadata/labels") //nolint:gosec + if updatedMap, ok := patch[0].Value.(map[string]string); ok { //nolint:gosec assert.Equal(t, len(updatedMap), 2) assert.Equal(t, strings.HasPrefix(updatedMap[constants.CanonicalLabelApplicationID], constants.AutoGenAppPrefix), true) assert.Equal(t, strings.HasPrefix(updatedMap[constants.LabelApplicationID], constants.AutoGenAppPrefix), true) diff --git a/pkg/common/utils/utils_test.go b/pkg/common/utils/utils_test.go index 4a469ca7d..b4fa6259a 100644 --- a/pkg/common/utils/utils_test.go +++ b/pkg/common/utils/utils_test.go @@ -510,6 +510,7 @@ func TestPodUnderCondition(t *testing.T) { assert.Equal(t, PodUnderCondition(pod, condition), false) } +// nolint: funlen func TestGetApplicationIDFromPod(t *testing.T) { defer SetPluginMode(false) defer func() { conf.GetSchedulerConf().GenerateUniqueAppIds = false }()