From e9fed7a488a0cddfeb1e21b9f98202e91692352f Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Mon, 29 Apr 2024 20:13:37 +0200 Subject: [PATCH] found NPE --- models/forgefed/activity_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/models/forgefed/activity_test.go b/models/forgefed/activity_test.go index 3cfe230d62..a81ea925ba 100644 --- a/models/forgefed/activity_test.go +++ b/models/forgefed/activity_test.go @@ -4,6 +4,7 @@ package forgefed import ( + "fmt" "reflect" "testing" "time" @@ -37,7 +38,7 @@ func Test_NewForgeLike(t *testing.T) { } } -func Test_StarMarshalJSON(t *testing.T) { +func Test_LikeMarshalJSON(t *testing.T) { type testPair struct { item ForgeLike want []byte @@ -75,7 +76,7 @@ func Test_StarMarshalJSON(t *testing.T) { } } -func Test_StarUnmarshalJSON(t *testing.T) { +func Test_LikeUnmarshalJSON(t *testing.T) { type testPair struct { item []byte want *ForgeLike @@ -93,6 +94,10 @@ func Test_StarUnmarshalJSON(t *testing.T) { }, }, }, + "wrong": { + item: []byte(`{"type":"Wrong","actor":"https://repo.prod.meissa.de/api/activitypub/user-id/1","object":"https://codeberg.org/api/activitypub/repository-id/1"}`), + wantErr: fmt.Errorf("an other error"), + }, } for name, tt := range tests { @@ -104,7 +109,7 @@ func Test_StarUnmarshalJSON(t *testing.T) { return } if !reflect.DeepEqual(got, tt.want) { - t.Errorf("UnmarshalJSON() got = %q, want %q", got, tt.want) + t.Errorf("UnmarshalJSON() got = %q, want %q, err %q", got, tt.want, err.Error()) } }) }