MCPcopy Create free account
hub / github.com/containerd/nerdctl / TestFormatInspectSlice

Function TestFormatInspectSlice

pkg/formatter/formatter_test.go:242–274  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

240}
241
242func TestFormatInspectSlice(t *testing.T) {
243 t.Parallel()
244
245 t.Run("empty slice is ignored", func(t *testing.T) {
246 t.Parallel()
247
248 var buf bytes.Buffer
249 err := FormatInspectSlice("{{.ID}}", &buf, nil)
250 assert.NilError(t, err)
251 assert.Equal(t, "", buf.String())
252 })
253
254 t.Run("malformed template returns error", func(t *testing.T) {
255 t.Parallel()
256
257 var buf bytes.Buffer
258 err := FormatInspectSlice("{{bad", &buf, []interface{}{
259 map[string]string{"ID": "abc"},
260 })
261 assert.ErrorContains(t, err, "template")
262 })
263
264 t.Run("default format still works", func(t *testing.T) {
265 t.Parallel()
266
267 var buf bytes.Buffer
268 err := FormatInspectSlice("", &buf, []interface{}{
269 map[string]string{"ID": "abc"},
270 })
271 assert.NilError(t, err)
272 assert.Assert(t, buf.Len() > 0)
273 })
274}

Callers

nothing calls this directly

Calls 4

FormatInspectSliceFunction · 0.85
AssertMethod · 0.80
RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…