From 5b28f7c14e5cc71a4e510c85ad636ec72a75f514 Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Thu, 8 Aug 2024 11:24:05 -0700 Subject: [PATCH] mstdn/ent.Status --- ent/status.go | 7 +------ ent/status_marshaljson_test.go | 7 ++++--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/ent/status.go b/ent/status.go index 3cb4ebf..6af1dcd 100644 --- a/ent/status.go +++ b/ent/status.go @@ -3,14 +3,13 @@ package ent import ( gojson "encoding/json" - "github.com/reiver/go-json" "github.com/reiver/go-jsonint" "github.com/reiver/go-opt" "github.com/reiver/go-nul" ) type Status struct { - ID opt.Optional[string] `json:"id"` + ID opt.Optional[string] `json:"id,omitempty"` URI nul.Nullable[string] `json:"uri,omitempty"` URL nul.Nullable[string] `json:"url,omitempty"` CreatedAt opt.Optional[string] `json:"created_at,omitempty"` @@ -42,7 +41,3 @@ type Status struct { Pinned opt.Optional[bool] `json:"pinned,omitempty"` Filtered gojson.RawMessage `json:"filtered,omitempty"` } - -func (receiver *Status) MarshalJSON() ([]byte, error) { - return json.Marshal(*receiver) -} diff --git a/ent/status_marshaljson_test.go b/ent/status_marshaljson_test.go index cdbf05b..2f0fa83 100644 --- a/ent/status_marshaljson_test.go +++ b/ent/status_marshaljson_test.go @@ -3,8 +3,9 @@ package ent import ( "testing" - "encoding/json" + gojson "encoding/json" + "github.com/reiver/go-json" "github.com/reiver/go-nul" "github.com/reiver/go-opt" ) @@ -164,7 +165,7 @@ func TestStatus_JSON(t *testing.T) { { Status:Status{ ID: opt.Something("123"), - Filtered: json.RawMessage([]byte(`{"once":1,"twice":2,"thrice":3,"fource":4}`)), + Filtered: gojson.RawMessage([]byte(`{"once":1,"twice":2,"thrice":3,"fource":4}`)), }, Expected: `{"id":"123","filtered":{"once":1,"twice":2,"thrice":3,"fource":4}}`, }, @@ -172,7 +173,7 @@ func TestStatus_JSON(t *testing.T) { for testNumber, test := range tests { - actualBytes, err := json.Marshal(&test.Status) + actualBytes, err := json.Marshal(test.Status) if nil != err { t.Errorf("For test #%d, did not expect to get an error but actually did.", testNumber)