(t *testing.T)
| 306 | } |
| 307 | |
| 308 | func TestRenderYAML(t *testing.T) { |
| 309 | w := httptest.NewRecorder() |
| 310 | data := ` |
| 311 | a : Easy! |
| 312 | b: |
| 313 | c: 2 |
| 314 | d: [3, 4] |
| 315 | ` |
| 316 | (YAML{data}).WriteContentType(w) |
| 317 | assert.Equal(t, "application/yaml; charset=utf-8", w.Header().Get("Content-Type")) |
| 318 | |
| 319 | err := (YAML{data}).Render(w) |
| 320 | require.NoError(t, err) |
| 321 | |
| 322 | // With github.com/goccy/go-yaml, the output format is different from gopkg.in/yaml.v3 |
| 323 | // We're checking that the output contains the expected data, not the exact formatting |
| 324 | output := w.Body.String() |
| 325 | assert.Contains(t, output, "a : Easy!") |
| 326 | assert.Contains(t, output, "b:") |
| 327 | assert.Contains(t, output, "c: 2") |
| 328 | assert.Contains(t, output, "d: [3, 4]") |
| 329 | assert.Equal(t, "application/yaml; charset=utf-8", w.Header().Get("Content-Type")) |
| 330 | } |
| 331 | |
| 332 | type fail struct{} |
| 333 |
nothing calls this directly
no test coverage detected