(t *testing.T)
| 445 | } |
| 446 | |
| 447 | func TestSupportsAttributes(t *testing.T) { |
| 448 | testModel := &Blog{ |
| 449 | ID: 5, |
| 450 | Title: "Title 1", |
| 451 | CreatedAt: time.Now(), |
| 452 | } |
| 453 | |
| 454 | out := bytes.NewBuffer(nil) |
| 455 | if err := MarshalPayload(out, testModel); err != nil { |
| 456 | t.Fatal(err) |
| 457 | } |
| 458 | |
| 459 | resp := new(OnePayload) |
| 460 | if err := json.NewDecoder(out).Decode(resp); err != nil { |
| 461 | t.Fatal(err) |
| 462 | } |
| 463 | |
| 464 | data := resp.Data |
| 465 | |
| 466 | if data.Attributes == nil { |
| 467 | t.Fatalf("Expected attributes") |
| 468 | } |
| 469 | |
| 470 | if !bytes.Equal(data.Attributes["title"], json.RawMessage(`"Title 1"`)) { |
| 471 | t.Fatalf("Attributes hash not populated using tags correctly") |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | func TestOmitsZeroTimes(t *testing.T) { |
| 476 | testModel := &Blog{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…