(t *testing.T)
| 240 | } |
| 241 | |
| 242 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…