test Protobuf rendering
(t *testing.T)
| 365 | |
| 366 | // test Protobuf rendering |
| 367 | func TestRenderProtoBuf(t *testing.T) { |
| 368 | w := httptest.NewRecorder() |
| 369 | reps := []int64{int64(1), int64(2)} |
| 370 | label := "test" |
| 371 | data := &testdata.Test{ |
| 372 | Label: &label, |
| 373 | Reps: reps, |
| 374 | } |
| 375 | |
| 376 | (ProtoBuf{data}).WriteContentType(w) |
| 377 | protoData, err := proto.Marshal(data) |
| 378 | require.NoError(t, err) |
| 379 | assert.Equal(t, "application/x-protobuf", w.Header().Get("Content-Type")) |
| 380 | |
| 381 | err = (ProtoBuf{data}).Render(w) |
| 382 | |
| 383 | require.NoError(t, err) |
| 384 | assert.Equal(t, string(protoData), w.Body.String()) |
| 385 | assert.Equal(t, "application/x-protobuf", w.Header().Get("Content-Type")) |
| 386 | } |
| 387 | |
| 388 | func TestRenderProtoBufFail(t *testing.T) { |
| 389 | w := httptest.NewRecorder() |