MCPcopy Create free account
hub / github.com/containerd/cgroups / TestGetKVStatsFileContentUint64

Function TestGetKVStatsFileContentUint64

cgroup2/utils_test.go:143–239  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

141}
142
143func TestGetKVStatsFileContentUint64(t *testing.T) {
144 testCases := []struct {
145 name string
146 fileContent string
147 propertyName string
148 expected uint64
149 }{
150 {
151 name: "valid property found",
152 fileContent: `some_key 123
153another_key 456
154third_key 789`,
155 propertyName: "another_key",
156 expected: 456,
157 },
158 {
159 name: "property at beginning",
160 fileContent: `first_key 999
161second_key 888`,
162 propertyName: "first_key",
163 expected: 999,
164 },
165 {
166 name: "property at end",
167 fileContent: `first_key 111
168second_key 222
169third_key 333`,
170 propertyName: "third_key",
171 expected: 333,
172 },
173 {
174 name: "property not found",
175 fileContent: `key1 100
176key2 200`,
177 propertyName: "missing_key",
178 expected: 0,
179 },
180 {
181 name: "invalid format - single field",
182 fileContent: `invalid_line
183valid_key 42`,
184 propertyName: "valid_key",
185 expected: 42,
186 },
187 {
188 name: "invalid format - three fields",
189 fileContent: `invalid key 1 2
190valid_key 100`,
191 propertyName: "valid_key",
192 expected: 100,
193 },
194 {
195 name: "invalid number format",
196 fileContent: `key1 not_a_number
197key2 500`,
198 propertyName: "key1",
199 expected: 0,
200 },

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…