mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
7994443c15
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
21 lines
584 B
Go
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())
|
|
}
|