(t *testing.T)
| 393 | } |
| 394 | |
| 395 | func TestRenderBSON(t *testing.T) { |
| 396 | w := httptest.NewRecorder() |
| 397 | reps := []int64{int64(1), int64(2)} |
| 398 | type mystruct struct { |
| 399 | Label string |
| 400 | Reps []int64 |
| 401 | } |
| 402 | |
| 403 | data := &mystruct{ |
| 404 | Label: "test", |
| 405 | Reps: reps, |
| 406 | } |
| 407 | |
| 408 | (BSON{data}).WriteContentType(w) |
| 409 | bsonData, err := bson.Marshal(data) |
| 410 | require.NoError(t, err) |
| 411 | assert.Equal(t, "application/bson", w.Header().Get("Content-Type")) |
| 412 | |
| 413 | err = (BSON{data}).Render(w) |
| 414 | |
| 415 | require.NoError(t, err) |
| 416 | assert.Equal(t, bsonData, w.Body.Bytes()) |
| 417 | assert.Equal(t, "application/bson", w.Header().Get("Content-Type")) |
| 418 | } |
| 419 | |
| 420 | func TestRenderBSONError(t *testing.T) { |
| 421 | w := httptest.NewRecorder() |
nothing calls this directly
no test coverage detected