mirror of https://github.com/writeas/writefreely
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
95215aa39d
@ -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