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
Vincent Demeester 42f6fdf059
Move integration-cli/request to internal/test/request…
… and change a bit the method signature

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-04-17 16:25:59 +02:00

49 lines
1.3 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"
"github.com/docker/docker/internal/test/request"
"github.com/gotestyourself/gotestyourself/assert"
is "github.com/gotestyourself/gotestyourself/assert/cmp"
)
func TestPsFilter(t *testing.T) {
defer setupTest(t)()
client := request.NewAPIClient(t)
ctx := context.Background()
prev := container.Create(t, ctx, client)
top := container.Create(t, ctx, client)
next := container.Create(t, ctx, client)
containerIDs := func(containers []types.Container) []string {
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))
}