1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration/internal/container/ns.go
Akihiro Suda 7994443c15
integration: port TestRunModePIDHost from CLI test to API test
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-02-01 14:54:07 +09:00

21 lines
584 B
Go

package container
import (
"context"
"strings"
"testing"
"github.com/docker/docker/client"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
// GetContainerNS gets the value of the specified namespace of a container
func GetContainerNS(ctx context.Context, t *testing.T, client client.APIClient, cID, nsName string) string {
t.Helper()
res, err := Exec(ctx, client, cID, []string{"readlink", "/proc/self/ns/" + nsName})
assert.NilError(t, err)
assert.Assert(t, is.Len(res.Stderr(), 0))
assert.Equal(t, 0, res.ExitCode)
return strings.TrimSpace(res.Stdout())
}