Skip to content

Commit

Permalink
Merge pull request #257 from Abirdcfly/mini
Browse files Browse the repository at this point in the history
chore: fix golangci-lint error in tests
  • Loading branch information
bjwswang authored Aug 15, 2023
2 parents 8022505 + cd619a1 commit 4910337
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions api/v1alpha1/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type condStatusTestCase struct {
status, exp ConditionedStatus
l int
cond Condition
}

func TestUpdateCondwithFixedLen(t *testing.T) {
type condStatusTestCase struct {
name string
status, exp ConditionedStatus
l int
cond Condition
}
now := metav1.Now()
testCases := []condStatusTestCase{
// l = 0
{
name: "l = 0",
status: ConditionedStatus{},
l: 0,
exp: ConditionedStatus{
Conditions: []Condition{{}},
},
},
// l = 1 && conditions = 0
{
name: "l = 1 && conditions = 0",
status: ConditionedStatus{},
l: 1,
cond: Condition{
Expand All @@ -68,8 +68,8 @@ func TestUpdateCondwithFixedLen(t *testing.T) {
},
},
},
// l = 1 && conditions = 1
{
name: "l = 1 && conditions = 1",
status: ConditionedStatus{
Conditions: []Condition{
{
Expand Down Expand Up @@ -101,8 +101,8 @@ func TestUpdateCondwithFixedLen(t *testing.T) {
},
},
},
// l = 1, conditions = 2
{
name: "l = 1, conditions = 2",
status: ConditionedStatus{
Conditions: []Condition{
{
Expand Down Expand Up @@ -141,9 +141,8 @@ func TestUpdateCondwithFixedLen(t *testing.T) {
},
},
},

// l = 2 && conditions = 0
{
name: "l = 2 && conditions = 0",
status: ConditionedStatus{},
l: 2,
cond: Condition{
Expand All @@ -165,10 +164,8 @@ func TestUpdateCondwithFixedLen(t *testing.T) {
},
},
},

// l = 2 && conditions = 1
// 6
{
name: "l = 2 && conditions = 1",
status: ConditionedStatus{
Conditions: []Condition{
{
Expand Down Expand Up @@ -207,8 +204,8 @@ func TestUpdateCondwithFixedLen(t *testing.T) {
},
},
},
// l = 2, conditions = 2
{
name: "l = 2, conditions = 2",
status: ConditionedStatus{
Conditions: []Condition{
{
Expand Down Expand Up @@ -254,8 +251,8 @@ func TestUpdateCondwithFixedLen(t *testing.T) {
},
},
},
// l =2 && conditions = 3
{
name: "l = 2, conditions = 3",
status: ConditionedStatus{
Conditions: []Condition{
{
Expand Down Expand Up @@ -310,7 +307,7 @@ func TestUpdateCondwithFixedLen(t *testing.T) {
},
}
for i, tc := range testCases {
t.Run(fmt.Sprintf(""), func(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
UpdateCondWithFixedLen(tc.l, &tc.status, tc.cond)
if !reflect.DeepEqual(tc.exp, tc.status) {
t.Fatalf("[%d] expect %v get %v", i, tc.exp, tc.status)
Expand Down

0 comments on commit 4910337

Please sign in to comment.