1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration/container/ps_test.go
Sebastiaan van Stijn b4c46b0dac
integration: change container.Create signature to fix linting
```
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>
2019-06-07 13:04:44 +02:00

48 lines
1.2 KiB
Go

package container // import "github.com/docker/docker/integration/container"
import (
"context"
"testing"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/integration/internal/container"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
)
func TestPsFilter(t *testing.T) {
defer setupTest(t)()
client := testEnv.APIClient()
ctx := context.Background()
prev := container.Create(ctx, t, client)
top := container.Create(ctx, t, client)
next := container.Create(ctx, t, client)
containerIDs := func(containers []types.Container) []string {
var entries []string
for _, container := range containers {
entries = append(entries, container.ID)
}
return entries
}
f1 := filters.NewArgs()
f1.Add("since", top)
q1, err := client.ContainerList(ctx, types.ContainerListOptions{
All: true,
Filters: f1,
})
assert.NilError(t, err)
assert.Check(t, is.Contains(containerIDs(q1), next))
f2 := filters.NewArgs()
f2.Add("before", top)
q2, err := client.ContainerList(ctx, types.ContainerListOptions{
All: true,
Filters: f2,
})
assert.NilError(t, err)
assert.Check(t, is.Contains(containerIDs(q2), prev))
}