Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyulin0719 committed Jul 12, 2024
1 parent 2676127 commit 4766471
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
30 changes: 15 additions & 15 deletions pkg/admission/admission_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions pkg/common/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 }()
Expand Down

0 comments on commit 4766471

Please sign in to comment.