Skip to content

Commit

Permalink
add test coverage of Marshal
Browse files Browse the repository at this point in the history
  • Loading branch information
chlowell authored and bgavrilMS committed Sep 25, 2024
1 parent 49a6639 commit 00bffc2
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion apps/internal/json/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type StructE struct {
AdditionalFields map[string]interface{}
}

func TestUnmarshal(t *testing.T) {
func TestUnmarshalRoundTrip(t *testing.T) {
now := time.Now()
nowJSON, err := now.MarshalJSON()
if err != nil {
Expand Down Expand Up @@ -147,6 +147,21 @@ func TestUnmarshal(t *testing.T) {
}
if diff := (&pretty.Config{IncludeUnexported: false}).Compare(test.want, test.got); diff != "" {
t.Errorf("TestUnmarshal(%s): -want/+got:\n%s", test.desc, diff)
continue
}
b, err := Marshal(test.got)
if err != nil {
t.Errorf("TestUnmarshal(%s): Marshal failed: %s", test.desc, err)
continue
}
err = Unmarshal(b, test.got)
if err != nil {
t.Errorf("TestUnmarshal(%s): Unmarshal round trip failed: %s", test.desc, err)
continue
}
if diff := (&pretty.Config{IncludeUnexported: false}).Compare(test.want, test.got); diff != "" {
t.Errorf("TestUnmarshal(%s): Round trip failed. -want/+got:\n%s", test.desc, diff)
continue
}
}
}
Expand Down

0 comments on commit 00bffc2

Please sign in to comment.