```
Line 25: warning: context.Context should be the first parameter of a function (golint)
Line 44: warning: context.Context should be the first parameter of a function (golint)
Line 52: warning: context.Context should be the first parameter of a function (golint)
```
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -19,7 +19,7 @@ func TestCopyFromContainerPathDoesNotExist(t *testing.T) {
|
| 19 | 19 |
|
| 20 | 20 |
ctx := context.Background() |
| 21 | 21 |
apiclient := testEnv.APIClient() |
| 22 |
- cid := container.Create(t, ctx, apiclient) |
|
| 22 |
+ cid := container.Create(ctx, t, apiclient) |
|
| 23 | 23 |
|
| 24 | 24 |
_, _, err := apiclient.CopyFromContainer(ctx, cid, "/dne") |
| 25 | 25 |
assert.Check(t, client.IsErrNotFound(err)) |
| ... | ... |
@@ -33,7 +33,7 @@ func TestCopyFromContainerPathIsNotDir(t *testing.T) {
|
| 33 | 33 |
|
| 34 | 34 |
ctx := context.Background() |
| 35 | 35 |
apiclient := testEnv.APIClient() |
| 36 |
- cid := container.Create(t, ctx, apiclient) |
|
| 36 |
+ cid := container.Create(ctx, t, apiclient) |
|
| 37 | 37 |
|
| 38 | 38 |
_, _, err := apiclient.CopyFromContainer(ctx, cid, "/etc/passwd/") |
| 39 | 39 |
assert.Assert(t, is.ErrorContains(err, "not a directory")) |
| ... | ... |
@@ -45,7 +45,7 @@ func TestCopyToContainerPathDoesNotExist(t *testing.T) {
|
| 45 | 45 |
|
| 46 | 46 |
ctx := context.Background() |
| 47 | 47 |
apiclient := testEnv.APIClient() |
| 48 |
- cid := container.Create(t, ctx, apiclient) |
|
| 48 |
+ cid := container.Create(ctx, t, apiclient) |
|
| 49 | 49 |
|
| 50 | 50 |
err := apiclient.CopyToContainer(ctx, cid, "/dne", nil, types.CopyToContainerOptions{})
|
| 51 | 51 |
assert.Check(t, client.IsErrNotFound(err)) |
| ... | ... |
@@ -59,7 +59,7 @@ func TestCopyToContainerPathIsNotDir(t *testing.T) {
|
| 59 | 59 |
|
| 60 | 60 |
ctx := context.Background() |
| 61 | 61 |
apiclient := testEnv.APIClient() |
| 62 |
- cid := container.Create(t, ctx, apiclient) |
|
| 62 |
+ cid := container.Create(ctx, t, apiclient) |
|
| 63 | 63 |
|
| 64 | 64 |
err := apiclient.CopyToContainer(ctx, cid, "/etc/passwd/", nil, types.CopyToContainerOptions{})
|
| 65 | 65 |
assert.Assert(t, is.ErrorContains(err, "not a directory")) |
| ... | ... |
@@ -40,7 +40,7 @@ func TestContainerStartOnDaemonRestart(t *testing.T) {
|
| 40 | 40 |
|
| 41 | 41 |
ctx := context.Background() |
| 42 | 42 |
|
| 43 |
- cID := container.Create(t, ctx, c) |
|
| 43 |
+ cID := container.Create(ctx, t, c) |
|
| 44 | 44 |
defer c.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true})
|
| 45 | 45 |
|
| 46 | 46 |
err := c.ContainerStart(ctx, cID, types.ContainerStartOptions{})
|
| ... | ... |
@@ -308,7 +308,7 @@ func TestIpcModeOlderClient(t *testing.T) {
|
| 308 | 308 |
ctx := context.Background() |
| 309 | 309 |
|
| 310 | 310 |
// pre-check: default ipc mode in daemon is private |
| 311 |
- cID := container.Create(t, ctx, c, container.WithAutoRemove) |
|
| 311 |
+ cID := container.Create(ctx, t, c, container.WithAutoRemove) |
|
| 312 | 312 |
|
| 313 | 313 |
inspect, err := c.ContainerInspect(ctx, cID) |
| 314 | 314 |
assert.NilError(t, err) |
| ... | ... |
@@ -316,7 +316,7 @@ func TestIpcModeOlderClient(t *testing.T) {
|
| 316 | 316 |
|
| 317 | 317 |
// main check: using older client creates "shareable" container |
| 318 | 318 |
c = request.NewAPIClient(t, client.WithVersion("1.39"))
|
| 319 |
- cID = container.Create(t, ctx, c, container.WithAutoRemove) |
|
| 319 |
+ cID = container.Create(ctx, t, c, container.WithAutoRemove) |
|
| 320 | 320 |
|
| 321 | 321 |
inspect, err = c.ContainerInspect(ctx, cID) |
| 322 | 322 |
assert.NilError(t, err) |
| ... | ... |
@@ -113,7 +113,7 @@ func TestKillStoppedContainer(t *testing.T) {
|
| 113 | 113 |
defer setupTest(t)() |
| 114 | 114 |
ctx := context.Background() |
| 115 | 115 |
client := testEnv.APIClient() |
| 116 |
- id := container.Create(t, ctx, client) |
|
| 116 |
+ id := container.Create(ctx, t, client) |
|
| 117 | 117 |
err := client.ContainerKill(ctx, id, "SIGKILL") |
| 118 | 118 |
assert.Assert(t, is.ErrorContains(err, "")) |
| 119 | 119 |
assert.Assert(t, is.Contains(err.Error(), "is not running")) |
| ... | ... |
@@ -124,7 +124,7 @@ func TestKillStoppedContainerAPIPre120(t *testing.T) {
|
| 124 | 124 |
defer setupTest(t)() |
| 125 | 125 |
ctx := context.Background() |
| 126 | 126 |
client := request.NewAPIClient(t, client.WithVersion("1.19"))
|
| 127 |
- id := container.Create(t, ctx, client) |
|
| 127 |
+ id := container.Create(ctx, t, client) |
|
| 128 | 128 |
err := client.ContainerKill(ctx, id, "SIGKILL") |
| 129 | 129 |
assert.NilError(t, err) |
| 130 | 130 |
} |
| ... | ... |
@@ -16,9 +16,9 @@ func TestPsFilter(t *testing.T) {
|
| 16 | 16 |
client := testEnv.APIClient() |
| 17 | 17 |
ctx := context.Background() |
| 18 | 18 |
|
| 19 |
- prev := container.Create(t, ctx, client) |
|
| 20 |
- top := container.Create(t, ctx, client) |
|
| 21 |
- next := container.Create(t, ctx, client) |
|
| 19 |
+ prev := container.Create(ctx, t, client) |
|
| 20 |
+ top := container.Create(ctx, t, client) |
|
| 21 |
+ next := container.Create(ctx, t, client) |
|
| 22 | 22 |
|
| 23 | 23 |
containerIDs := func(containers []types.Container) []string {
|
| 24 | 24 |
var entries []string |
| ... | ... |
@@ -51,7 +51,7 @@ func testCreateFailureWithCgroupNs(t *testing.T, daemonNsMode string, errStr str |
| 51 | 51 |
|
| 52 | 52 |
d.StartWithBusybox(t) |
| 53 | 53 |
defer d.Stop(t) |
| 54 |
- container.CreateExpectingErr(t, ctx, client, errStr, containerOpts...) |
|
| 54 |
+ container.CreateExpectingErr(ctx, t, client, errStr, containerOpts...) |
|
| 55 | 55 |
} |
| 56 | 56 |
|
| 57 | 57 |
func TestCgroupNamespacesRun(t *testing.T) {
|
| ... | ... |
@@ -19,7 +19,7 @@ func TestCommitInheritsEnv(t *testing.T) {
|
| 19 | 19 |
client := testEnv.APIClient() |
| 20 | 20 |
ctx := context.Background() |
| 21 | 21 |
|
| 22 |
- cID1 := container.Create(t, ctx, client) |
|
| 22 |
+ cID1 := container.Create(ctx, t, client) |
|
| 23 | 23 |
|
| 24 | 24 |
commitResp1, err := client.ContainerCommit(ctx, cID1, types.ContainerCommitOptions{
|
| 25 | 25 |
Changes: []string{"ENV PATH=/bin"},
|
| ... | ... |
@@ -33,7 +33,7 @@ func TestCommitInheritsEnv(t *testing.T) {
|
| 33 | 33 |
expectedEnv1 := []string{"PATH=/bin"}
|
| 34 | 34 |
assert.Check(t, is.DeepEqual(expectedEnv1, image1.Config.Env)) |
| 35 | 35 |
|
| 36 |
- cID2 := container.Create(t, ctx, client, container.WithImage(image1.ID)) |
|
| 36 |
+ cID2 := container.Create(ctx, t, client, container.WithImage(image1.ID)) |
|
| 37 | 37 |
|
| 38 | 38 |
commitResp2, err := client.ContainerCommit(ctx, cID2, types.ContainerCommitOptions{
|
| 39 | 39 |
Changes: []string{"ENV PATH=/usr/bin:$PATH"},
|
| ... | ... |
@@ -20,7 +20,7 @@ func TestRemoveImageOrphaning(t *testing.T) {
|
| 20 | 20 |
img := "test-container-orphaning" |
| 21 | 21 |
|
| 22 | 22 |
// Create a container from busybox, and commit a small change so we have a new image |
| 23 |
- cID1 := container.Create(t, ctx, client, container.WithCmd(""))
|
|
| 23 |
+ cID1 := container.Create(ctx, t, client, container.WithCmd(""))
|
|
| 24 | 24 |
commitResp1, err := client.ContainerCommit(ctx, cID1, types.ContainerCommitOptions{
|
| 25 | 25 |
Changes: []string{`ENTRYPOINT ["true"]`},
|
| 26 | 26 |
Reference: img, |
| ... | ... |
@@ -33,7 +33,7 @@ func TestRemoveImageOrphaning(t *testing.T) {
|
| 33 | 33 |
assert.Check(t, is.Equal(resp.ID, commitResp1.ID)) |
| 34 | 34 |
|
| 35 | 35 |
// Create a container from created image, and commit a small change with same reference name |
| 36 |
- cID2 := container.Create(t, ctx, client, container.WithImage(img), container.WithCmd(""))
|
|
| 36 |
+ cID2 := container.Create(ctx, t, client, container.WithImage(img), container.WithCmd(""))
|
|
| 37 | 37 |
commitResp2, err := client.ContainerCommit(ctx, cID2, types.ContainerCommitOptions{
|
| 38 | 38 |
Changes: []string{`LABEL Maintainer="Integration Tests"`},
|
| 39 | 39 |
Reference: img, |
| ... | ... |
@@ -21,8 +21,7 @@ type TestContainerConfig struct {
|
| 21 | 21 |
} |
| 22 | 22 |
|
| 23 | 23 |
// create creates a container with the specified options |
| 24 |
-// nolint: golint |
|
| 25 |
-func create(t *testing.T, ctx context.Context, client client.APIClient, ops ...func(*TestContainerConfig)) (container.ContainerCreateCreatedBody, error) { // nolint: golint
|
|
| 24 |
+func create(ctx context.Context, t *testing.T, client client.APIClient, ops ...func(*TestContainerConfig)) (container.ContainerCreateCreatedBody, error) {
|
|
| 26 | 25 |
t.Helper() |
| 27 | 26 |
config := &TestContainerConfig{
|
| 28 | 27 |
Config: &container.Config{
|
| ... | ... |
@@ -41,16 +40,16 @@ func create(t *testing.T, ctx context.Context, client client.APIClient, ops ...f |
| 41 | 41 |
} |
| 42 | 42 |
|
| 43 | 43 |
// Create creates a container with the specified options, asserting that there was no error |
| 44 |
-func Create(t *testing.T, ctx context.Context, client client.APIClient, ops ...func(*TestContainerConfig)) string { // nolint: golint
|
|
| 45 |
- c, err := create(t, ctx, client, ops...) |
|
| 44 |
+func Create(ctx context.Context, t *testing.T, client client.APIClient, ops ...func(*TestContainerConfig)) string {
|
|
| 45 |
+ c, err := create(ctx, t, client, ops...) |
|
| 46 | 46 |
assert.NilError(t, err) |
| 47 | 47 |
|
| 48 | 48 |
return c.ID |
| 49 | 49 |
} |
| 50 | 50 |
|
| 51 | 51 |
// CreateExpectingErr creates a container, expecting an error with the specified message |
| 52 |
-func CreateExpectingErr(t *testing.T, ctx context.Context, client client.APIClient, errMsg string, ops ...func(*TestContainerConfig)) { // nolint: golint
|
|
| 53 |
- _, err := create(t, ctx, client, ops...) |
|
| 52 |
+func CreateExpectingErr(ctx context.Context, t *testing.T, client client.APIClient, errMsg string, ops ...func(*TestContainerConfig)) {
|
|
| 53 |
+ _, err := create(ctx, t, client, ops...) |
|
| 54 | 54 |
assert.ErrorContains(t, err, errMsg) |
| 55 | 55 |
} |
| 56 | 56 |
|
| ... | ... |
@@ -58,7 +57,7 @@ func CreateExpectingErr(t *testing.T, ctx context.Context, client client.APIClie |
| 58 | 58 |
// nolint: golint |
| 59 | 59 |
func Run(t *testing.T, ctx context.Context, client client.APIClient, ops ...func(*TestContainerConfig)) string { // nolint: golint
|
| 60 | 60 |
t.Helper() |
| 61 |
- id := Create(t, ctx, client, ops...) |
|
| 61 |
+ id := Create(ctx, t, client, ops...) |
|
| 62 | 62 |
|
| 63 | 63 |
err := client.ContainerStart(ctx, id, types.ContainerStartOptions{})
|
| 64 | 64 |
assert.NilError(t, err) |
| ... | ... |
@@ -29,7 +29,7 @@ func TestDockerNetworkConnectAlias(t *testing.T) {
|
| 29 | 29 |
net.WithAttachable(), |
| 30 | 30 |
) |
| 31 | 31 |
|
| 32 |
- cID1 := container.Create(t, ctx, client, func(c *container.TestContainerConfig) {
|
|
| 32 |
+ cID1 := container.Create(ctx, t, client, func(c *container.TestContainerConfig) {
|
|
| 33 | 33 |
c.NetworkingConfig = &network.NetworkingConfig{
|
| 34 | 34 |
EndpointsConfig: map[string]*network.EndpointSettings{
|
| 35 | 35 |
name: {},
|
| ... | ... |
@@ -52,7 +52,7 @@ func TestDockerNetworkConnectAlias(t *testing.T) {
|
| 52 | 52 |
assert.Check(t, is.Equal(len(ng1.NetworkSettings.Networks[name].Aliases), 2)) |
| 53 | 53 |
assert.Check(t, is.Equal(ng1.NetworkSettings.Networks[name].Aliases[0], "aaa")) |
| 54 | 54 |
|
| 55 |
- cID2 := container.Create(t, ctx, client, func(c *container.TestContainerConfig) {
|
|
| 55 |
+ cID2 := container.Create(ctx, t, client, func(c *container.TestContainerConfig) {
|
|
| 56 | 56 |
c.NetworkingConfig = &network.NetworkingConfig{
|
| 57 | 57 |
EndpointsConfig: map[string]*network.EndpointSettings{
|
| 58 | 58 |
name: {},
|
| ... | ... |
@@ -41,7 +41,7 @@ func TestCgroupDriverSystemdMemoryLimit(t *testing.T) {
|
| 41 | 41 |
const mem = 64 * 1024 * 1024 // 64 MB |
| 42 | 42 |
|
| 43 | 43 |
ctx := context.Background() |
| 44 |
- ctrID := container.Create(t, ctx, c, func(ctr *container.TestContainerConfig) {
|
|
| 44 |
+ ctrID := container.Create(ctx, t, c, func(ctr *container.TestContainerConfig) {
|
|
| 45 | 45 |
ctr.HostConfig.Resources.Memory = mem |
| 46 | 46 |
}) |
| 47 | 47 |
defer c.ContainerRemove(ctx, ctrID, types.ContainerRemoveOptions{Force: true})
|
| ... | ... |
@@ -83,7 +83,7 @@ func TestEventsBackwardsCompatible(t *testing.T) {
|
| 83 | 83 |
since := request.DaemonTime(ctx, t, client, testEnv) |
| 84 | 84 |
ts := strconv.FormatInt(since.Unix(), 10) |
| 85 | 85 |
|
| 86 |
- cID := container.Create(t, ctx, client) |
|
| 86 |
+ cID := container.Create(ctx, t, client) |
|
| 87 | 87 |
|
| 88 | 88 |
// In case there is no events, the API should have responded immediately (not blocking), |
| 89 | 89 |
// The test here makes sure the response time is less than 3 sec. |
| ... | ... |
@@ -64,7 +64,7 @@ func TestVolumesRemove(t *testing.T) {
|
| 64 | 64 |
|
| 65 | 65 |
prefix, slash := getPrefixAndSlashFromDaemonPlatform() |
| 66 | 66 |
|
| 67 |
- id := container.Create(t, ctx, client, container.WithVolume(prefix+slash+"foo")) |
|
| 67 |
+ id := container.Create(ctx, t, client, container.WithVolume(prefix+slash+"foo")) |
|
| 68 | 68 |
|
| 69 | 69 |
c, err := client.ContainerInspect(ctx, id) |
| 70 | 70 |
assert.NilError(t, err) |