fixes issue #100 - can't follow from pubgate
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.gopull/111/head
parent
3986c8eec1
commit
ff2d3fc3d5
@ -0,0 +1,3 @@
|
||||
{
|
||||
"go.formatTool": "goimports"
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue