1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-09-15 18:56:59 +00:00

revise NewForgeLike

Also added new test, which still fails since time.Now() does not match
This commit is contained in:
Clemens 2024-03-27 16:20:33 +01:00
parent 911e916a4f
commit 97b5e0da91
2 changed files with 26 additions and 8 deletions

View file

@ -12,6 +12,30 @@ import (
ap "github.com/go-ap/activitypub"
)
// TODO: fix this test. mock time.Now?
func Test_NewForgeLike(t *testing.T) {
actorIRI := "https://repo.prod.meissa.de/api/v1/activitypub/user-id/1"
objectIRI := "https://codeberg.org/api/v1/activitypub/repository-id/1"
want := []byte(`{"type":"Like","actor":"https://repo.prod.meissa.de/api/v1/activitypub/user-id/1","object":"https://codeberg.org/api/v1/activitypub/repository-id/1"}`)
sut, err := NewForgeLike(actorIRI, objectIRI)
if err != nil {
t.Errorf("unexpected error: %v\n", err)
}
if valid, _ := validation.IsValid(sut); !valid {
t.Errorf("sut expected to be valid: %v\n", sut.Validate())
}
got, err := sut.MarshalJSON()
if err != nil {
t.Errorf("MarshalJSON() error = \"%v\"", err)
return
}
if !reflect.DeepEqual(got, want) {
t.Errorf("MarshalJSON() got = %q, want %q", got, want)
}
}
func Test_StarMarshalJSON(t *testing.T) {
type testPair struct {
item ForgeLike