MCPcopy Create free account
hub / github.com/pace/bricks / TestSupportsAttributes

Function TestSupportsAttributes

http/jsonapi/response_test.go:447–473  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

445}
446
447func 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
475func TestOmitsZeroTimes(t *testing.T) {
476 testModel := &Blog{

Callers

nothing calls this directly

Calls 4

MarshalPayloadFunction · 0.85
NowMethod · 0.80
FatalMethod · 0.80
FatalfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…