mirror of
https://github.com/writefreely/writefreely
synced 2024-11-24 17:43:05 +00:00
ff2d3fc3d5
this moves the unmarshaling of a remote actor out into a new helper which accounts for the possibility of a context being a list or a single entity. i.e. a string or an object. basics tests are provided for both situations also go fmt'd the file activitypub.go
31 lines
574 B
Go
31 lines
574 B
Go
package writefreely
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/writeas/web-core/activitystreams"
|
|
)
|
|
|
|
var actorTestTable = []struct {
|
|
Name string
|
|
Resp []byte
|
|
}{
|
|
{
|
|
"Context as a string",
|
|
[]byte(`{"@context":"https://www.w3.org/ns/activitystreams"}`),
|
|
},
|
|
{
|
|
"Context as a list",
|
|
[]byte(`{"@context":["one string", "two strings"]}`),
|
|
},
|
|
}
|
|
|
|
func TestUnmarshalActor(t *testing.T) {
|
|
for _, tc := range actorTestTable {
|
|
actor := activitystreams.Person{}
|
|
err := unmarshalActor(tc.Resp, &actor)
|
|
if err != nil {
|
|
t.Errorf("%s failed with error %s", tc.Name, err)
|
|
}
|
|
}
|
|
}
|