MCPcopy
hub / github.com/containerd/containerd / TestRootPair

Function TestRootPair

internal/userns/idmap_test.go:26–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestRootPair(t *testing.T) {
27 for _, test := range []struct {
28 idmap IDMap
29 expUID uint32
30 expGID uint32
31 expErr bool
32 }{
33 {
34 idmap: IDMap{
35 UidMap: []specs.LinuxIDMapping{
36 {
37 ContainerID: 0,
38 HostID: 100,
39 Size: 1,
40 },
41 },
42 GidMap: []specs.LinuxIDMapping{
43 {
44 ContainerID: 0,
45 HostID: 200,
46 Size: 1,
47 },
48 },
49 },
50 expUID: 100,
51 expGID: 200,
52 expErr: false,
53 },
54 {
55 idmap: IDMap{
56 UidMap: []specs.LinuxIDMapping{
57 {
58 ContainerID: 1,
59 HostID: 100,
60 Size: 1,
61 },
62 },
63 },
64 expUID: invalidID,
65 expGID: invalidID,
66 expErr: true,
67 },
68 } {
69 user, err := test.idmap.RootPair()
70 assert.Equal(t, test.expErr, err != nil)
71 assert.Equal(t, test.expUID, user.Uid)
72 assert.Equal(t, test.expGID, user.Gid)
73 }
74}
75
76func TestToHost(t *testing.T) {
77 idmap := IDMap{

Callers

nothing calls this directly

Calls 1

RootPairMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…