MCPcopy Create free account
hub / github.com/containerd/containerd / TestRemappedGID

Function TestRemappedGID

core/runtime/v2/bundle_linux_test.go:88–143  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

86}
87
88func TestRemappedGID(t *testing.T) {
89 tests := []struct {
90 spec oci.Spec
91 gid uint32
92 }{{
93 // empty spec
94 spec: oci.Spec{},
95 gid: 0,
96 }, {
97 // empty Linux section
98 spec: oci.Spec{
99 Linux: &specs.Linux{},
100 },
101 gid: 0,
102 }, {
103 // empty ID mappings
104 spec: oci.Spec{
105 Linux: &specs.Linux{
106 GIDMappings: make([]specs.LinuxIDMapping, 0),
107 },
108 },
109 gid: 0,
110 }, {
111 // valid ID mapping
112 spec: oci.Spec{
113 Linux: &specs.Linux{
114 GIDMappings: []specs.LinuxIDMapping{{
115 ContainerID: 0,
116 HostID: 1000,
117 }},
118 },
119 },
120 gid: 1000,
121 }, {
122 // missing ID mapping
123 spec: oci.Spec{
124 Linux: &specs.Linux{
125 GIDMappings: []specs.LinuxIDMapping{{
126 ContainerID: 100,
127 HostID: 1000,
128 }},
129 },
130 },
131 gid: 0,
132 }}
133
134 for i, tc := range tests {
135 t.Run(strconv.Itoa(i), func(t *testing.T) {
136 s, err := json.Marshal(tc.spec)
137 require.NoError(t, err, "failed to marshal spec")
138 gid, err := remappedGID(s)
139 assert.NoError(t, err, "should unmarshal successfully")
140 assert.Equal(t, tc.gid, gid, "expected GID to match")
141 })
142 }
143}

Callers

nothing calls this directly

Calls 3

remappedGIDFunction · 0.85
RunMethod · 0.65
MarshalMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…