Browse code

integration: copy loop variable into parallel test closures

Discovered a few instances, where loop variable is incorrectly used
within a test closure, which is marked as parallel.
Few of these were actually loops over singleton slices, therefore the issue
might not have surfaced there (yet), but it is good to fix there as
well, as this is an incorrect pattern used across different tests.

Signed-off-by: Roman Volosatovs <roman.volosatovs@docker.com>

Roman Volosatovs authored on 2021/07/23 05:41:01
Showing 4 changed files
... ...
@@ -19,6 +19,7 @@ func TestContainerInvalidJSON(t *testing.T) {
19 19
 	}
20 20
 
21 21
 	for _, ep := range endpoints {
22
+		ep := ep
22 23
 		t.Run(ep, func(t *testing.T) {
23 24
 			t.Parallel()
24 25
 
... ...
@@ -72,6 +72,7 @@ func TestNetworkInvalidJSON(t *testing.T) {
72 72
 	}
73 73
 
74 74
 	for _, ep := range endpoints {
75
+		ep := ep
75 76
 		t.Run(ep, func(t *testing.T) {
76 77
 			t.Parallel()
77 78
 
... ...
@@ -105,6 +106,7 @@ func TestNetworkList(t *testing.T) {
105 105
 	}
106 106
 
107 107
 	for _, ep := range endpoints {
108
+		ep := ep
108 109
 		t.Run(ep, func(t *testing.T) {
109 110
 			t.Parallel()
110 111
 
... ...
@@ -36,6 +36,7 @@ func TestPluginInvalidJSON(t *testing.T) {
36 36
 	endpoints := []string{"/plugins/foobar/set"}
37 37
 
38 38
 	for _, ep := range endpoints {
39
+		ep := ep
39 40
 		t.Run(ep, func(t *testing.T) {
40 41
 			t.Parallel()
41 42
 
... ...
@@ -110,6 +110,7 @@ func TestVolumesInvalidJSON(t *testing.T) {
110 110
 	endpoints := []string{"/volumes/create"}
111 111
 
112 112
 	for _, ep := range endpoints {
113
+		ep := ep
113 114
 		t.Run(ep, func(t *testing.T) {
114 115
 			t.Parallel()
115 116