mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 10:53:34 +00:00
build: address 'copyloopvar' linter warning
golangci-lint reports these: The copy of the 'for' variable "kmsID" can be deleted (Go 1.22+) (copyloopvar) Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
9321fe03c3
commit
0e7b06e9d0
@ -43,14 +43,13 @@ func TestGetIPRange(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
ts := tt
|
||||
t.Run(ts.cidr, func(t *testing.T) {
|
||||
t.Run(tt.cidr, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
got, err := getIPRange(ts.cidr)
|
||||
got, err := getIPRange(tt.cidr)
|
||||
require.NoError(t, err)
|
||||
|
||||
// validate if number of IPs in the range is same as expected, if not, fail.
|
||||
require.ElementsMatch(t, ts.expectedIPs, got)
|
||||
require.ElementsMatch(t, tt.expectedIPs, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -86,20 +85,18 @@ func TestFetchIP(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
ts := tt
|
||||
|
||||
t.Run(ts.clientInfo, func(t *testing.T) {
|
||||
t.Run(tt.clientInfo, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client := activeClient{Inst: ts.clientInfo}
|
||||
client := activeClient{Inst: tt.clientInfo}
|
||||
ip, actualErr := client.fetchIP()
|
||||
|
||||
if (actualErr != nil) != ts.expectedErr {
|
||||
t.Errorf("expected error %v but got %v", ts.expectedErr, actualErr)
|
||||
if (actualErr != nil) != tt.expectedErr {
|
||||
t.Errorf("expected error %v but got %v", tt.expectedErr, actualErr)
|
||||
}
|
||||
|
||||
if ip != ts.expectedIP {
|
||||
t.Errorf("expected IP %s but got %s", ts.expectedIP, ip)
|
||||
if ip != tt.expectedIP {
|
||||
t.Errorf("expected IP %s but got %s", tt.expectedIP, ip)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -126,18 +123,17 @@ func TestFetchID(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
ts := tt
|
||||
t.Run(ts.clientInfo, func(t *testing.T) {
|
||||
t.Run(tt.clientInfo, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ac := &activeClient{Inst: ts.clientInfo}
|
||||
ac := &activeClient{Inst: tt.clientInfo}
|
||||
actualID, actualErr := ac.fetchID()
|
||||
|
||||
if (actualErr != nil) != ts.expectedErr {
|
||||
t.Errorf("expected error %v but got %v", ts.expectedErr, actualErr)
|
||||
if (actualErr != nil) != tt.expectedErr {
|
||||
t.Errorf("expected error %v but got %v", tt.expectedErr, actualErr)
|
||||
}
|
||||
|
||||
if actualID != ts.expectedID {
|
||||
t.Errorf("expected ID %d but got %d", ts.expectedID, actualID)
|
||||
if actualID != tt.expectedID {
|
||||
t.Errorf("expected ID %d but got %d", tt.expectedID, actualID)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -71,7 +71,6 @@ func TestValidateSchedulingInterval(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
err := validateSchedulingInterval(tt.interval)
|
||||
@ -147,7 +146,6 @@ func TestValidateSchedulingDetails(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
err := validateSchedulingDetails(ctx, tt.parameters)
|
||||
@ -203,7 +201,6 @@ func TestGetSchedulingDetails(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
interval, startTime := getSchedulingDetails(tt.parameters)
|
||||
@ -251,11 +248,10 @@ func TestCheckVolumeResyncStatus(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
ts := tt
|
||||
t.Run(ts.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if err := checkVolumeResyncStatus(ctx, ts.args); (err != nil) != ts.wantErr {
|
||||
t.Errorf("checkVolumeResyncStatus() error = %v, expect error = %v", err, ts.wantErr)
|
||||
if err := checkVolumeResyncStatus(ctx, tt.args); (err != nil) != tt.wantErr {
|
||||
t.Errorf("checkVolumeResyncStatus() error = %v, expect error = %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -388,11 +384,10 @@ func TestCheckRemoteSiteStatus(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
ts := tt
|
||||
t.Run(ts.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if ready := checkRemoteSiteStatus(context.TODO(), &ts.args); ready != ts.wantReady {
|
||||
t.Errorf("checkRemoteSiteStatus() ready = %v, expect ready = %v", ready, ts.wantReady)
|
||||
if ready := checkRemoteSiteStatus(context.TODO(), &tt.args); ready != tt.wantReady {
|
||||
t.Errorf("checkRemoteSiteStatus() ready = %v, expect ready = %v", ready, tt.wantReady)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -501,7 +496,6 @@ func TestValidateLastSyncInfo(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
teststruct, err := getLastSyncInfo(ctx, tt.description)
|
||||
@ -600,7 +594,6 @@ func TestGetGRPCError(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
result := getGRPCError(tt.err)
|
||||
@ -656,7 +649,6 @@ func Test_timestampFromString(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
got, err := timestampFromString(tt.timestamp)
|
||||
|
Reference in New Issue
Block a user