golangci-lint: govet: enable shadow check

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2023-11-20 13:04:09 +01:00
parent 606cbd60a1
commit 2d61f70f00
9 changed files with 81 additions and 74 deletions

View File

@ -70,7 +70,7 @@ func TestReplicatedProgressUpdaterOneReplica(t *testing.T) {
}
p := &mockProgress{}
updaterTester := updaterTester{
ut := updaterTester{
t: t,
updater: &replicatedProgressUpdater{
progressOut: p,
@ -82,7 +82,7 @@ func TestReplicatedProgressUpdaterOneReplica(t *testing.T) {
tasks := []swarm.Task{}
updaterTester.testUpdater(tasks, false,
ut.testUpdater(tasks, false,
[]progress.Progress{
{ID: "overall progress", Action: "0 out of 1 tasks"},
{ID: "1/1", Action: " "},
@ -97,14 +97,14 @@ func TestReplicatedProgressUpdaterOneReplica(t *testing.T) {
DesiredState: swarm.TaskStateShutdown,
Status: swarm.TaskStatus{State: swarm.TaskStateNew},
})
updaterTester.testUpdater(tasks, false,
ut.testUpdater(tasks, false,
[]progress.Progress{
{ID: "overall progress", Action: "0 out of 1 tasks"},
})
// Task with valid DesiredState and State updates progress bar
tasks[0].DesiredState = swarm.TaskStateRunning
updaterTester.testUpdater(tasks, false,
ut.testUpdater(tasks, false,
[]progress.Progress{
{ID: "1/1", Action: "new ", Current: 1, Total: 9, HideCounts: true},
{ID: "overall progress", Action: "0 out of 1 tasks"},
@ -113,7 +113,7 @@ func TestReplicatedProgressUpdaterOneReplica(t *testing.T) {
// If the task exposes an error, we should show that instead of the
// progress bar.
tasks[0].Status.Err = "something is wrong"
updaterTester.testUpdater(tasks, false,
ut.testUpdater(tasks, false,
[]progress.Progress{
{ID: "1/1", Action: "something is wrong"},
{ID: "overall progress", Action: "0 out of 1 tasks"},
@ -122,7 +122,7 @@ func TestReplicatedProgressUpdaterOneReplica(t *testing.T) {
// When the task reaches running, update should return true
tasks[0].Status.Err = ""
tasks[0].Status.State = swarm.TaskStateRunning
updaterTester.testUpdater(tasks, true,
ut.testUpdater(tasks, true,
[]progress.Progress{
{ID: "1/1", Action: "running ", Current: 9, Total: 9, HideCounts: true},
{ID: "overall progress", Action: "1 out of 1 tasks"},
@ -131,7 +131,7 @@ func TestReplicatedProgressUpdaterOneReplica(t *testing.T) {
// If the task fails, update should return false again
tasks[0].Status.Err = "task failed"
tasks[0].Status.State = swarm.TaskStateFailed
updaterTester.testUpdater(tasks, false,
ut.testUpdater(tasks, false,
[]progress.Progress{
{ID: "1/1", Action: "task failed"},
{ID: "overall progress", Action: "0 out of 1 tasks"},
@ -147,7 +147,7 @@ func TestReplicatedProgressUpdaterOneReplica(t *testing.T) {
DesiredState: swarm.TaskStateRunning,
Status: swarm.TaskStatus{State: swarm.TaskStateRunning},
})
updaterTester.testUpdater(tasks, true,
ut.testUpdater(tasks, true,
[]progress.Progress{
{ID: "1/1", Action: "running ", Current: 9, Total: 9, HideCounts: true},
{ID: "overall progress", Action: "1 out of 1 tasks"},
@ -162,7 +162,7 @@ func TestReplicatedProgressUpdaterOneReplica(t *testing.T) {
DesiredState: swarm.TaskStateRunning,
Status: swarm.TaskStatus{State: swarm.TaskStatePreparing},
})
updaterTester.testUpdater(tasks, false,
ut.testUpdater(tasks, false,
[]progress.Progress{
{ID: "1/1", Action: "preparing", Current: 6, Total: 9, HideCounts: true},
{ID: "overall progress", Action: "0 out of 1 tasks"},
@ -183,7 +183,7 @@ func TestReplicatedProgressUpdaterManyReplicas(t *testing.T) {
}
p := &mockProgress{}
updaterTester := updaterTester{
ut := updaterTester{
t: t,
updater: &replicatedProgressUpdater{
progressOut: p,
@ -196,7 +196,7 @@ func TestReplicatedProgressUpdaterManyReplicas(t *testing.T) {
tasks := []swarm.Task{}
// No per-task progress bars because there are too many replicas
updaterTester.testUpdater(tasks, false,
ut.testUpdater(tasks, false,
[]progress.Progress{
{ID: "overall progress", Action: fmt.Sprintf("0 out of %d tasks", replicas)},
{ID: "overall progress", Action: fmt.Sprintf("0 out of %d tasks", replicas)},
@ -215,13 +215,13 @@ func TestReplicatedProgressUpdaterManyReplicas(t *testing.T) {
if i%2 == 1 {
tasks[i].NodeID = "b"
}
updaterTester.testUpdater(tasks, false,
ut.testUpdater(tasks, false,
[]progress.Progress{
{ID: "overall progress", Action: fmt.Sprintf("%d out of %d tasks", i, replicas)},
})
tasks[i].Status.State = swarm.TaskStateRunning
updaterTester.testUpdater(tasks, uint64(i) == replicas-1,
ut.testUpdater(tasks, uint64(i) == replicas-1,
[]progress.Progress{
{ID: "overall progress", Action: fmt.Sprintf("%d out of %d tasks", i+1, replicas)},
})
@ -238,7 +238,7 @@ func TestGlobalProgressUpdaterOneNode(t *testing.T) {
}
p := &mockProgress{}
updaterTester := updaterTester{
ut := updaterTester{
t: t,
updater: &globalProgressUpdater{
progressOut: p,
@ -250,7 +250,7 @@ func TestGlobalProgressUpdaterOneNode(t *testing.T) {
tasks := []swarm.Task{}
updaterTester.testUpdater(tasks, false,
ut.testUpdater(tasks, false,
[]progress.Progress{
{ID: "overall progress", Action: "waiting for new tasks"},
})
@ -263,7 +263,7 @@ func TestGlobalProgressUpdaterOneNode(t *testing.T) {
DesiredState: swarm.TaskStateShutdown,
Status: swarm.TaskStatus{State: swarm.TaskStateNew},
})
updaterTester.testUpdater(tasks, false,
ut.testUpdater(tasks, false,
[]progress.Progress{
{ID: "overall progress", Action: "0 out of 1 tasks"},
{ID: "overall progress", Action: "0 out of 1 tasks"},
@ -271,7 +271,7 @@ func TestGlobalProgressUpdaterOneNode(t *testing.T) {
// Task with valid DesiredState and State updates progress bar
tasks[0].DesiredState = swarm.TaskStateRunning
updaterTester.testUpdater(tasks, false,
ut.testUpdater(tasks, false,
[]progress.Progress{
{ID: "a", Action: "new ", Current: 1, Total: 9, HideCounts: true},
{ID: "overall progress", Action: "0 out of 1 tasks"},
@ -280,7 +280,7 @@ func TestGlobalProgressUpdaterOneNode(t *testing.T) {
// If the task exposes an error, we should show that instead of the
// progress bar.
tasks[0].Status.Err = "something is wrong"
updaterTester.testUpdater(tasks, false,
ut.testUpdater(tasks, false,
[]progress.Progress{
{ID: "a", Action: "something is wrong"},
{ID: "overall progress", Action: "0 out of 1 tasks"},
@ -289,7 +289,7 @@ func TestGlobalProgressUpdaterOneNode(t *testing.T) {
// When the task reaches running, update should return true
tasks[0].Status.Err = ""
tasks[0].Status.State = swarm.TaskStateRunning
updaterTester.testUpdater(tasks, true,
ut.testUpdater(tasks, true,
[]progress.Progress{
{ID: "a", Action: "running ", Current: 9, Total: 9, HideCounts: true},
{ID: "overall progress", Action: "1 out of 1 tasks"},
@ -298,7 +298,7 @@ func TestGlobalProgressUpdaterOneNode(t *testing.T) {
// If the task fails, update should return false again
tasks[0].Status.Err = "task failed"
tasks[0].Status.State = swarm.TaskStateFailed
updaterTester.testUpdater(tasks, false,
ut.testUpdater(tasks, false,
[]progress.Progress{
{ID: "a", Action: "task failed"},
{ID: "overall progress", Action: "0 out of 1 tasks"},
@ -314,7 +314,7 @@ func TestGlobalProgressUpdaterOneNode(t *testing.T) {
DesiredState: swarm.TaskStateRunning,
Status: swarm.TaskStatus{State: swarm.TaskStateRunning},
})
updaterTester.testUpdater(tasks, true,
ut.testUpdater(tasks, true,
[]progress.Progress{
{ID: "a", Action: "running ", Current: 9, Total: 9, HideCounts: true},
{ID: "overall progress", Action: "1 out of 1 tasks"},
@ -329,7 +329,7 @@ func TestGlobalProgressUpdaterOneNode(t *testing.T) {
DesiredState: swarm.TaskStateRunning,
Status: swarm.TaskStatus{State: swarm.TaskStatePreparing},
})
updaterTester.testUpdater(tasks, false,
ut.testUpdater(tasks, false,
[]progress.Progress{
{ID: "a", Action: "preparing", Current: 6, Total: 9, HideCounts: true},
{ID: "overall progress", Action: "0 out of 1 tasks"},
@ -348,7 +348,7 @@ func TestGlobalProgressUpdaterManyNodes(t *testing.T) {
}
p := &mockProgress{}
updaterTester := updaterTester{
ut := updaterTester{
t: t,
updater: &globalProgressUpdater{
progressOut: p,
@ -359,12 +359,12 @@ func TestGlobalProgressUpdaterManyNodes(t *testing.T) {
}
for i := 0; i != nodes; i++ {
updaterTester.activeNodes[strconv.Itoa(i)] = struct{}{}
ut.activeNodes[strconv.Itoa(i)] = struct{}{}
}
tasks := []swarm.Task{}
updaterTester.testUpdater(tasks, false,
ut.testUpdater(tasks, false,
[]progress.Progress{
{ID: "overall progress", Action: "waiting for new tasks"},
})
@ -379,7 +379,7 @@ func TestGlobalProgressUpdaterManyNodes(t *testing.T) {
})
}
updaterTester.testUpdater(tasks, false,
ut.testUpdater(tasks, false,
[]progress.Progress{
{ID: "overall progress", Action: fmt.Sprintf("0 out of %d tasks", nodes)},
{ID: "overall progress", Action: fmt.Sprintf("0 out of %d tasks", nodes)},
@ -387,7 +387,7 @@ func TestGlobalProgressUpdaterManyNodes(t *testing.T) {
for i := 0; i != nodes; i++ {
tasks[i].Status.State = swarm.TaskStateRunning
updaterTester.testUpdater(tasks, i == nodes-1,
ut.testUpdater(tasks, i == nodes-1,
[]progress.Progress{
{ID: "overall progress", Action: fmt.Sprintf("%d out of %d tasks", i+1, nodes)},
})