Moved integration tests back to their own folder
This commit is contained in:
parent
882dcd90be
commit
cd46437bf2
24 changed files with 212 additions and 207 deletions
|
@ -1,16 +1,17 @@
|
|||
package activitypub
|
||||
package tests
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
j "github.com/go-ap/jsonld"
|
||||
|
||||
pub "github.com/go-ap/activitypub"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func TestAcceptSerialization(t *testing.T) {
|
||||
obj := AcceptNew("https://localhost/myactivity", nil)
|
||||
obj.Name = make(NaturalLanguageValues, 1)
|
||||
obj := pub.AcceptNew("https://localhost/myactivity", nil)
|
||||
obj.Name = make(pub.NaturalLanguageValues, 1)
|
||||
obj.Name.Set("en", "test")
|
||||
obj.Name.Set("fr", "teste")
|
||||
|
||||
|
@ -40,11 +41,11 @@ func TestAcceptSerialization(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreateActivityHTTPSerialization(t *testing.T) {
|
||||
id := ObjectID("test_object")
|
||||
obj := AcceptNew(id, nil)
|
||||
id := pub.ObjectID("test_object")
|
||||
obj := pub.AcceptNew(id, nil)
|
||||
obj.Name.Set("en", "Accept New")
|
||||
|
||||
uri := string(ActivityBaseURI)
|
||||
uri := string(pub.ActivityBaseURI)
|
||||
|
||||
data, err := j.WithContext(j.IRI(uri)).Marshal(obj)
|
||||
if err != nil {
|
|
@ -1,4 +1,4 @@
|
|||
package activitypub
|
||||
package tests
|
||||
|
||||
// Common server tests...
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
package activitypub
|
||||
package tests
|
||||
|
||||
// Server to Server tests from: https://test.activitypub.rocks/
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
pub "github.com/go-ap/activitypub"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -21,9 +22,9 @@ S2S Server: Activities requiring the object property
|
|||
`
|
||||
t.Log(desc)
|
||||
|
||||
obj := MentionNew("gigel")
|
||||
obj := pub.MentionNew("gigel")
|
||||
|
||||
add := AddNew("https://localhost/myactivity", obj, nil)
|
||||
add := pub.AddNew("https://localhost/myactivity", obj, nil)
|
||||
if add.Object == nil {
|
||||
t.Errorf("Missing GetID in Add activity %#v", add.Object)
|
||||
}
|
||||
|
@ -31,7 +32,7 @@ S2S Server: Activities requiring the object property
|
|||
t.Errorf("Add.GetID different than what we initialized %#v %#v", add.Object, obj)
|
||||
}
|
||||
|
||||
block := BlockNew("https://localhost/myactivity", obj)
|
||||
block := pub.BlockNew("https://localhost/myactivity", obj)
|
||||
if block.Object == nil {
|
||||
t.Errorf("Missing GetID in Add activity %#v", block.Object)
|
||||
}
|
||||
|
@ -39,7 +40,7 @@ S2S Server: Activities requiring the object property
|
|||
t.Errorf("Block.GetID different than what we initialized %#v %#v", block.Object, obj)
|
||||
}
|
||||
|
||||
create := CreateNew("https://localhost/myactivity", obj)
|
||||
create := pub.CreateNew("https://localhost/myactivity", obj)
|
||||
if create.Object == nil {
|
||||
t.Errorf("Missing GetID in Add activity %#v", create.Object)
|
||||
}
|
||||
|
@ -47,7 +48,7 @@ S2S Server: Activities requiring the object property
|
|||
t.Errorf("Create.GetID different than what we initialized %#v %#v", create.Object, obj)
|
||||
}
|
||||
|
||||
delete := DeleteNew("https://localhost/myactivity", obj)
|
||||
delete := pub.DeleteNew("https://localhost/myactivity", obj)
|
||||
if delete.Object == nil {
|
||||
t.Errorf("Missing GetID in Delete activity %#v", delete.Object)
|
||||
}
|
||||
|
@ -55,7 +56,7 @@ S2S Server: Activities requiring the object property
|
|||
t.Errorf("Delete.GetID different than what we initialized %#v %#v", delete.Object, obj)
|
||||
}
|
||||
|
||||
follow := FollowNew("https://localhost/myactivity", obj)
|
||||
follow := pub.FollowNew("https://localhost/myactivity", obj)
|
||||
if follow.Object == nil {
|
||||
t.Errorf("Missing GetID in Follow activity %#v", follow.Object)
|
||||
}
|
||||
|
@ -63,7 +64,7 @@ S2S Server: Activities requiring the object property
|
|||
t.Errorf("Follow.GetID different than what we initialized %#v %#v", follow.Object, obj)
|
||||
}
|
||||
|
||||
like := LikeNew("https://localhost/myactivity", obj)
|
||||
like := pub.LikeNew("https://localhost/myactivity", obj)
|
||||
if like.Object == nil {
|
||||
t.Errorf("Missing GetID in Like activity %#v", like.Object)
|
||||
}
|
||||
|
@ -71,7 +72,7 @@ S2S Server: Activities requiring the object property
|
|||
t.Errorf("Like.GetID different than what we initialized %#v %#v", add.Object, obj)
|
||||
}
|
||||
|
||||
update := UpdateNew("https://localhost/myactivity", obj)
|
||||
update := pub.UpdateNew("https://localhost/myactivity", obj)
|
||||
if update.Object == nil {
|
||||
t.Errorf("Missing GetID in Update activity %#v", update.Object)
|
||||
}
|
||||
|
@ -79,7 +80,7 @@ S2S Server: Activities requiring the object property
|
|||
t.Errorf("Update.GetID different than what we initialized %#v %#v", update.Object, obj)
|
||||
}
|
||||
|
||||
undo := UndoNew("https://localhost/myactivity", obj)
|
||||
undo := pub.UndoNew("https://localhost/myactivity", obj)
|
||||
if undo.Object == nil {
|
||||
t.Errorf("Missing GetID in Undo activity %#v", undo.Object)
|
||||
}
|
||||
|
@ -102,10 +103,10 @@ property: Add, Remove.
|
|||
`
|
||||
t.Log(desc)
|
||||
|
||||
obj := MentionNew("foo")
|
||||
target := MentionNew("bar")
|
||||
obj := pub.MentionNew("foo")
|
||||
target := pub.MentionNew("bar")
|
||||
|
||||
add := AddNew("https://localhost/myactivity", obj, target)
|
||||
add := pub.AddNew("https://localhost/myactivity", obj, target)
|
||||
if add.Target == nil {
|
||||
t.Errorf("Missing Target in Add activity %#v", add.Target)
|
||||
}
|
||||
|
@ -113,7 +114,7 @@ property: Add, Remove.
|
|||
t.Errorf("Add.Target different than what we initialized %#v %#v", add.Target, target)
|
||||
}
|
||||
|
||||
remove := RemoveNew("https://localhost/myactivity", obj, target)
|
||||
remove := pub.RemoveNew("https://localhost/myactivity", obj, target)
|
||||
if remove.Target == nil {
|
||||
t.Errorf("Missing Target in Remove activity %#v", remove.Target)
|
||||
}
|
||||
|
@ -140,19 +141,19 @@ S2S Server: Deduplication of recipient list
|
|||
`
|
||||
t.Log(desc)
|
||||
|
||||
to := PersonNew("bob")
|
||||
o := ObjectNew(ArticleType)
|
||||
cc := PersonNew("alice")
|
||||
to := pub.PersonNew("bob")
|
||||
o := pub.ObjectNew(pub.ArticleType)
|
||||
cc := pub.PersonNew("alice")
|
||||
|
||||
o.ID = "something"
|
||||
c := CreateNew("create", o)
|
||||
c := pub.CreateNew("create", o)
|
||||
c.To.Append(to)
|
||||
c.CC.Append(cc)
|
||||
c.BCC.Append(cc)
|
||||
|
||||
c.Recipients()
|
||||
|
||||
checkDedup := func(list ItemCollection, recIds *[]ObjectID) error {
|
||||
checkDedup := func(list pub.ItemCollection, recIds *[]pub.ObjectID) error {
|
||||
for _, rec := range list {
|
||||
for _, id := range *recIds {
|
||||
if rec.GetID() == id {
|
||||
|
@ -165,7 +166,7 @@ S2S Server: Deduplication of recipient list
|
|||
}
|
||||
|
||||
var err error
|
||||
recIds := make([]ObjectID, 0)
|
||||
recIds := make([]pub.ObjectID, 0)
|
||||
err = checkDedup(c.To, &recIds)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
@ -196,15 +197,15 @@ Activity being notified about
|
|||
`
|
||||
t.Log(desc)
|
||||
|
||||
p := PersonNew("main actor")
|
||||
p := pub.PersonNew("main actor")
|
||||
|
||||
to := PersonNew("bob")
|
||||
o := ObjectNew(ArticleType)
|
||||
cc := PersonNew("alice")
|
||||
to := pub.PersonNew("bob")
|
||||
o := pub.ObjectNew(pub.ArticleType)
|
||||
cc := pub.PersonNew("alice")
|
||||
|
||||
o.ID = "something"
|
||||
c := CreateNew("create", o)
|
||||
c.Actor = Actor(*p)
|
||||
c := pub.CreateNew("create", o)
|
||||
c.Actor = *p
|
||||
|
||||
c.To.Append(p)
|
||||
c.To.Append(to)
|
||||
|
@ -215,7 +216,7 @@ Activity being notified about
|
|||
|
||||
c.Recipients()
|
||||
|
||||
checkActor := func(list ItemCollection, actor Item) error {
|
||||
checkActor := func(list pub.ItemCollection, actor pub.Item) error {
|
||||
for _, rec := range list {
|
||||
if rec.GetID() == actor.GetID() {
|
||||
return fmt.Errorf("%T[%s] Actor of activity should not be in the recipients list", rec, actor.GetID())
|
||||
|
@ -253,13 +254,13 @@ S2S Server: Do-not-deliver considerations
|
|||
`
|
||||
t.Log(desc)
|
||||
|
||||
p := PersonNew("blocked")
|
||||
p := pub.PersonNew("blocked")
|
||||
|
||||
bob := PersonNew("bob")
|
||||
jane := PersonNew("jane doe")
|
||||
bob := pub.PersonNew("bob")
|
||||
jane := pub.PersonNew("jane doe")
|
||||
|
||||
b := BlockNew("block actor", p)
|
||||
b.Actor = Actor(*bob)
|
||||
b := pub.BlockNew("block actor", p)
|
||||
b.Actor = *bob
|
||||
|
||||
b.To.Append(jane)
|
||||
b.To.Append(p)
|
||||
|
@ -267,7 +268,7 @@ S2S Server: Do-not-deliver considerations
|
|||
|
||||
b.Recipients()
|
||||
|
||||
checkActor := func(list ItemCollection, ob Item) error {
|
||||
checkActor := func(list pub.ItemCollection, ob pub.Item) error {
|
||||
for _, rec := range list {
|
||||
if rec.GetID() == ob.GetID() {
|
||||
return fmt.Errorf("%T[%s] of activity should not be in the recipients list", rec, ob.GetID())
|
|
@ -1,8 +1,9 @@
|
|||
package activitypub
|
||||
package tests
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
pub "github.com/go-ap/activitypub"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -194,92 +195,94 @@ var zLoc, _ = time.LoadLocation("UTC")
|
|||
var allTests = testMaps{
|
||||
"empty": testPair{
|
||||
expected: true,
|
||||
blank: &Object{},
|
||||
result: &Object{},
|
||||
blank: &pub.Object{},
|
||||
result: &pub.Object{},
|
||||
},
|
||||
"link_simple": testPair{
|
||||
expected: true,
|
||||
blank: &Link{},
|
||||
result: &Link{
|
||||
Type: LinkType,
|
||||
Href: IRI("http://example.org/abc"),
|
||||
HrefLang: LangRef("en"),
|
||||
MediaType: MimeType("text/html"),
|
||||
Name: NaturalLanguageValues{{
|
||||
NilLangRef, "An example link",
|
||||
blank: &pub.Link{},
|
||||
result: &pub.Link{
|
||||
Type: pub.LinkType,
|
||||
Href: pub.IRI("http://example.org/abc"),
|
||||
HrefLang: pub.LangRef("en"),
|
||||
MediaType: pub.MimeType("text/html"),
|
||||
Name: pub.NaturalLanguageValues{{
|
||||
pub.NilLangRef, "An example link",
|
||||
}},
|
||||
},
|
||||
},
|
||||
"object_with_url": testPair{
|
||||
expected: true,
|
||||
blank: &Object{},
|
||||
result: &Object{
|
||||
URL: IRI("http://littr.git/api/accounts/system"),
|
||||
blank: &pub.Object{},
|
||||
result: &pub.Object{
|
||||
URL: pub.IRI("http://littr.git/api/accounts/system"),
|
||||
},
|
||||
},
|
||||
"object_with_url_collection": testPair{
|
||||
expected: true,
|
||||
blank: &Object{},
|
||||
result: &Object{
|
||||
URL: ItemCollection{
|
||||
IRI("http://littr.git/api/accounts/system"),
|
||||
IRI("http://littr.git/~system"),
|
||||
blank: &pub.Object{},
|
||||
result: &pub.Object{
|
||||
URL: pub.ItemCollection{
|
||||
pub.IRI("http://littr.git/api/accounts/system"),
|
||||
pub.IRI("http://littr.git/~system"),
|
||||
},
|
||||
},
|
||||
},
|
||||
"object_simple": testPair{
|
||||
expected: true,
|
||||
blank: &Object{},
|
||||
result: &Object{
|
||||
Type: ObjectType,
|
||||
ID: ObjectID("http://www.test.example/object/1"),
|
||||
Name: NaturalLanguageValues{{
|
||||
NilLangRef, "A Simple, non-specific object",
|
||||
blank: &pub.Object{},
|
||||
result: &pub.Object{
|
||||
Type: pub.ObjectType,
|
||||
ID: pub.ObjectID("http://www.test.example/object/1"),
|
||||
Name: pub.NaturalLanguageValues{{
|
||||
pub.NilLangRef, "A Simple, non-specific object",
|
||||
}},
|
||||
},
|
||||
},
|
||||
"object_with_tags": testPair{
|
||||
expected: true,
|
||||
blank: &Object{},
|
||||
result: &Object{
|
||||
Type: ObjectType,
|
||||
ID: ObjectID("http://www.test.example/object/1"),
|
||||
Name: NaturalLanguageValues{{
|
||||
NilLangRef, "A Simple, non-specific object",
|
||||
blank: &pub.Object{},
|
||||
result: &pub.Object{
|
||||
Type: pub.ObjectType,
|
||||
ID: pub.ObjectID("http://www.test.example/object/1"),
|
||||
Name: pub.NaturalLanguageValues{{
|
||||
pub.NilLangRef, "A Simple, non-specific object",
|
||||
}},
|
||||
Tag: ItemCollection{
|
||||
&Mention{
|
||||
Name: NaturalLanguageValues{{
|
||||
NilLangRef, "#my_tag",
|
||||
Tag: pub.ItemCollection{
|
||||
&pub.Mention{
|
||||
Name: pub.NaturalLanguageValues{{
|
||||
pub.NilLangRef, "#my_tag",
|
||||
}},
|
||||
Type: MentionType,
|
||||
ID: ObjectID("http://example.com/tag/my_tag"),
|
||||
Type: pub.MentionType,
|
||||
ID: pub.ObjectID("http://example.com/tag/my_tag"),
|
||||
},
|
||||
&Mention{
|
||||
Name: NaturalLanguageValues{{
|
||||
NilLangRef, "@ana",
|
||||
&pub.Mention{
|
||||
Name: pub.NaturalLanguageValues{{
|
||||
pub.NilLangRef, "@ana",
|
||||
}},
|
||||
Type: MentionType,
|
||||
ID: ObjectID("http://example.com/users/ana"),
|
||||
Type: pub.MentionType,
|
||||
ID: pub.ObjectID("http://example.com/users/ana"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"object_with_replies": testPair{
|
||||
expected: true,
|
||||
blank: &Object{},
|
||||
result: &Object{
|
||||
Type: ObjectType,
|
||||
ID: ObjectID("http://www.test.example/object/1"),
|
||||
Replies: &Collection{
|
||||
ID: ObjectID("http://www.test.example/object/1/replies"),
|
||||
Type: CollectionType,
|
||||
blank: &pub.Object{},
|
||||
result: &pub.Object{
|
||||
Type: pub.ObjectType,
|
||||
ID: pub.ObjectID("http://www.test.example/object/1"),
|
||||
Replies: &pub.Collection{
|
||||
ID: pub.ObjectID("http://www.test.example/object/1/replies"),
|
||||
Type: pub.CollectionType,
|
||||
TotalItems: 1,
|
||||
Items: ItemCollection{
|
||||
&Object{
|
||||
ID: ObjectID("http://www.test.example/object/1/replies/2"),
|
||||
Type: ArticleType,
|
||||
Name: NaturalLanguageValues{{NilLangRef, "Example title"}},
|
||||
Items: pub.ItemCollection{
|
||||
&pub.Object{
|
||||
ID: pub.ObjectID("http://www.test.example/object/1/replies/2"),
|
||||
Type: pub.ArticleType,
|
||||
Name: pub.NaturalLanguageValues{{
|
||||
pub.NilLangRef, "Example title",
|
||||
}},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -287,142 +290,142 @@ var allTests = testMaps{
|
|||
},
|
||||
"activity_simple": testPair{
|
||||
expected: true,
|
||||
blank: &Activity{
|
||||
Actor: &Person{},
|
||||
blank: &pub.Activity{
|
||||
Actor: &pub.Person{},
|
||||
},
|
||||
result: &Activity{
|
||||
Type: ActivityType,
|
||||
Summary: NaturalLanguageValues{{NilLangRef, "Sally did something to a note"}},
|
||||
Actor: &Person{
|
||||
Type: PersonType,
|
||||
Name: NaturalLanguageValues{{NilLangRef, "Sally"}},
|
||||
result: &pub.Activity{
|
||||
Type: pub.ActivityType,
|
||||
Summary: pub.NaturalLanguageValues{{pub.NilLangRef, "Sally did something to a note"}},
|
||||
Actor: &pub.Person{
|
||||
Type: pub.PersonType,
|
||||
Name: pub.NaturalLanguageValues{{pub.NilLangRef, "Sally"}},
|
||||
},
|
||||
Object: &Object{
|
||||
Type: NoteType,
|
||||
Name: NaturalLanguageValues{{NilLangRef, "A Note"}},
|
||||
Object: &pub.Object{
|
||||
Type: pub.NoteType,
|
||||
Name: pub.NaturalLanguageValues{{pub.NilLangRef, "A Note"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
"person_with_outbox": testPair{
|
||||
expected: true,
|
||||
blank: &Person{},
|
||||
result: &Person{
|
||||
ID: ObjectID("http://example.com/accounts/ana"),
|
||||
Type: PersonType,
|
||||
Name: NaturalLanguageValues{{NilLangRef, "ana"}},
|
||||
PreferredUsername: NaturalLanguageValues{{NilLangRef, "ana"}},
|
||||
URL: IRI("http://example.com/accounts/ana"),
|
||||
Outbox: &OrderedCollection{
|
||||
ID: "http://example.com/accounts/ana/outbox",
|
||||
Type: OrderedCollectionType,
|
||||
URL: IRI("http://example.com/outbox"),
|
||||
blank: &pub.Person{},
|
||||
result: &pub.Person{
|
||||
ID: pub.ObjectID("http://example.com/accounts/ana"),
|
||||
Type: pub.PersonType,
|
||||
Name: pub.NaturalLanguageValues{{pub.NilLangRef, "ana"}},
|
||||
PreferredUsername: pub.NaturalLanguageValues{{pub.NilLangRef, "ana"}},
|
||||
URL: pub.IRI("http://example.com/accounts/ana"),
|
||||
Outbox: &pub.OrderedCollection{
|
||||
ID: "http://example.com/accounts/ana/outbox",
|
||||
Type: pub.OrderedCollectionType,
|
||||
URL: pub.IRI("http://example.com/outbox"),
|
||||
},
|
||||
},
|
||||
},
|
||||
"ordered_collection": testPair{
|
||||
expected: true,
|
||||
blank: &OrderedCollection{},
|
||||
result: &OrderedCollection{
|
||||
ID: ObjectID("http://example.com/outbox"),
|
||||
Type: OrderedCollectionType,
|
||||
URL: IRI("http://example.com/outbox"),
|
||||
blank: &pub.OrderedCollection{},
|
||||
result: &pub.OrderedCollection{
|
||||
ID: pub.ObjectID("http://example.com/outbox"),
|
||||
Type: pub.OrderedCollectionType,
|
||||
URL: pub.IRI("http://example.com/outbox"),
|
||||
TotalItems: 1,
|
||||
OrderedItems: ItemCollection{
|
||||
&Object{
|
||||
ID: ObjectID("http://example.com/outbox/53c6fb47"),
|
||||
Type: ArticleType,
|
||||
Name: NaturalLanguageValues{{NilLangRef, "Example title"}},
|
||||
Content: NaturalLanguageValues{{NilLangRef, "Example content!"}},
|
||||
URL: IRI("http://example.com/53c6fb47"),
|
||||
MediaType: MimeType("text/markdown"),
|
||||
OrderedItems: pub.ItemCollection{
|
||||
&pub.Object{
|
||||
ID: pub.ObjectID("http://example.com/outbox/53c6fb47"),
|
||||
Type: pub.ArticleType,
|
||||
Name: pub.NaturalLanguageValues{{pub.NilLangRef, "Example title"}},
|
||||
Content: pub.NaturalLanguageValues{{pub.NilLangRef, "Example content!"}},
|
||||
URL: pub.IRI("http://example.com/53c6fb47"),
|
||||
MediaType: pub.MimeType("text/markdown"),
|
||||
Published: time.Date(2018, time.July, 5, 16, 46, 44, 0, zLoc),
|
||||
Generator: IRI("http://example.com"),
|
||||
AttributedTo: IRI("http://example.com/accounts/alice"),
|
||||
Generator: pub.IRI("http://example.com"),
|
||||
AttributedTo: pub.IRI("http://example.com/accounts/alice"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"ordered_collection_page": testPair{
|
||||
expected: true,
|
||||
blank: &OrderedCollectionPage{},
|
||||
result: &OrderedCollectionPage{
|
||||
PartOf: IRI("http://example.com/outbox"),
|
||||
Next: IRI("http://example.com/outbox?page=3"),
|
||||
Prev: IRI("http://example.com/outbox?page=1"),
|
||||
ID: ObjectID("http://example.com/outbox?page=2"),
|
||||
Type: OrderedCollectionPageType,
|
||||
URL: IRI("http://example.com/outbox?page=2"),
|
||||
Current: IRI("http://example.com/outbox?page=2"),
|
||||
blank: &pub.OrderedCollectionPage{},
|
||||
result: &pub.OrderedCollectionPage{
|
||||
PartOf: pub.IRI("http://example.com/outbox"),
|
||||
Next: pub.IRI("http://example.com/outbox?page=3"),
|
||||
Prev: pub.IRI("http://example.com/outbox?page=1"),
|
||||
ID: pub.ObjectID("http://example.com/outbox?page=2"),
|
||||
Type: pub.OrderedCollectionPageType,
|
||||
URL: pub.IRI("http://example.com/outbox?page=2"),
|
||||
Current: pub.IRI("http://example.com/outbox?page=2"),
|
||||
TotalItems: 1,
|
||||
OrderedItems: ItemCollection{
|
||||
&Object{
|
||||
ID: ObjectID("http://example.com/outbox/53c6fb47"),
|
||||
Type: ArticleType,
|
||||
Name: NaturalLanguageValues{{NilLangRef, "Example title"}},
|
||||
Content: NaturalLanguageValues{{NilLangRef, "Example content!"}},
|
||||
URL: IRI("http://example.com/53c6fb47"),
|
||||
MediaType: MimeType("text/markdown"),
|
||||
OrderedItems: pub.ItemCollection{
|
||||
&pub.Object{
|
||||
ID: pub.ObjectID("http://example.com/outbox/53c6fb47"),
|
||||
Type: pub.ArticleType,
|
||||
Name: pub.NaturalLanguageValues{{pub.NilLangRef, "Example title"}},
|
||||
Content: pub.NaturalLanguageValues{{pub.NilLangRef, "Example content!"}},
|
||||
URL: pub.IRI("http://example.com/53c6fb47"),
|
||||
MediaType: pub.MimeType("text/markdown"),
|
||||
Published: time.Date(2018, time.July, 5, 16, 46, 44, 0, zLoc),
|
||||
Generator: IRI("http://example.com"),
|
||||
AttributedTo: IRI("http://example.com/accounts/alice"),
|
||||
Generator: pub.IRI("http://example.com"),
|
||||
AttributedTo: pub.IRI("http://example.com/accounts/alice"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"natural_language_values": {
|
||||
expected: true,
|
||||
blank: &NaturalLanguageValues{},
|
||||
result: &NaturalLanguageValues{
|
||||
blank: &pub.NaturalLanguageValues{},
|
||||
result: &pub.NaturalLanguageValues{
|
||||
{
|
||||
NilLangRef, `
|
||||
pub.NilLangRef, `
|
||||
|
||||
`},
|
||||
{LangRef("en"), "Ana got apples ⓐ"},
|
||||
{LangRef("fr"), "Aná a des pommes ⒜"},
|
||||
{LangRef("ro"), "Ana are mere"},
|
||||
{pub.LangRef("en"), "Ana got apples ⓐ"},
|
||||
{pub.LangRef("fr"), "Aná a des pommes ⒜"},
|
||||
{pub.LangRef("ro"), "Ana are mere"},
|
||||
},
|
||||
},
|
||||
"activity_create_simple": {
|
||||
expected: true,
|
||||
blank: &Create{},
|
||||
result: &Create{
|
||||
Type: CreateType,
|
||||
Actor: IRI("https://littr.git/api/accounts/anonymous"),
|
||||
Object: &Object{
|
||||
Type: NoteType,
|
||||
AttributedTo: IRI("https://littr.git/api/accounts/anonymous"),
|
||||
InReplyTo: ItemCollection{IRI("https://littr.git/api/accounts/system/outbox/7ca154ff")},
|
||||
Content: NaturalLanguageValues{{NilLangRef, "<p>Hello world</p>"}},
|
||||
To: ItemCollection{IRI("https://www.w3.org/ns/activitystreams#Public")},
|
||||
blank: &pub.Create{},
|
||||
result: &pub.Create{
|
||||
Type: pub.CreateType,
|
||||
Actor: pub.IRI("https://littr.git/api/accounts/anonymous"),
|
||||
Object: &pub.Object{
|
||||
Type: pub.NoteType,
|
||||
AttributedTo: pub.IRI("https://littr.git/api/accounts/anonymous"),
|
||||
InReplyTo: pub.ItemCollection{pub.IRI("https://littr.git/api/accounts/system/outbox/7ca154ff")},
|
||||
Content: pub.NaturalLanguageValues{{pub.NilLangRef, "<p>Hello world</p>"}},
|
||||
To: pub.ItemCollection{pub.IRI("https://www.w3.org/ns/activitystreams#Public")},
|
||||
},
|
||||
},
|
||||
},
|
||||
"activity_create_multiple_objects": {
|
||||
expected: true,
|
||||
blank: &Create{},
|
||||
result: &Create{
|
||||
Type: CreateType,
|
||||
Actor: IRI("https://littr.git/api/accounts/anonymous"),
|
||||
Object: ItemCollection{
|
||||
&Object{
|
||||
Type: NoteType,
|
||||
AttributedTo: IRI("https://littr.git/api/accounts/anonymous"),
|
||||
InReplyTo: ItemCollection{IRI("https://littr.git/api/accounts/system/outbox/7ca154ff")},
|
||||
Content: NaturalLanguageValues{{NilLangRef, "<p>Hello world</p>"}},
|
||||
To: ItemCollection{IRI("https://www.w3.org/ns/activitystreams#Public")},
|
||||
blank: &pub.Create{},
|
||||
result: &pub.Create{
|
||||
Type: pub.CreateType,
|
||||
Actor: pub.IRI("https://littr.git/api/accounts/anonymous"),
|
||||
Object:pub.ItemCollection{
|
||||
&pub.Object{
|
||||
Type: pub.NoteType,
|
||||
AttributedTo: pub.IRI("https://littr.git/api/accounts/anonymous"),
|
||||
InReplyTo: pub.ItemCollection{pub.IRI("https://littr.git/api/accounts/system/outbox/7ca154ff")},
|
||||
Content: pub.NaturalLanguageValues{{pub.NilLangRef, "<p>Hello world</p>"}},
|
||||
To: pub.ItemCollection{pub.IRI("https://www.w3.org/ns/activitystreams#Public")},
|
||||
},
|
||||
&Article{
|
||||
Type: ArticleType,
|
||||
ID: ObjectID("http://www.test.example/article/1"),
|
||||
Name: NaturalLanguageValues{
|
||||
&pub.Article{
|
||||
Type: pub.ArticleType,
|
||||
ID: pub.ObjectID("http://www.test.example/article/1"),
|
||||
Name: pub.NaturalLanguageValues{
|
||||
{
|
||||
NilLangRef,
|
||||
pub.NilLangRef,
|
||||
"This someday will grow up to be an article",
|
||||
},
|
||||
},
|
||||
InReplyTo: ItemCollection{
|
||||
IRI("http://www.test.example/object/1"),
|
||||
IRI("http://www.test.example/object/778"),
|
||||
InReplyTo: pub.ItemCollection{
|
||||
pub.IRI("http://www.test.example/object/1"),
|
||||
pub.IRI("http://www.test.example/object/778"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -430,40 +433,40 @@ var allTests = testMaps{
|
|||
},
|
||||
"object_with_audience": testPair{
|
||||
expected: true,
|
||||
blank: &Object{},
|
||||
result: &Object{
|
||||
Type: ObjectType,
|
||||
ID: ObjectID("http://www.test.example/object/1"),
|
||||
To: ItemCollection{
|
||||
IRI("https://www.w3.org/ns/activitystreams#Public"),
|
||||
blank: &pub.Object{},
|
||||
result: &pub.Object{
|
||||
Type: pub.ObjectType,
|
||||
ID: pub.ObjectID("http://www.test.example/object/1"),
|
||||
To: pub.ItemCollection{
|
||||
pub.IRI("https://www.w3.org/ns/activitystreams#Public"),
|
||||
},
|
||||
Bto: ItemCollection{
|
||||
IRI("http://example.com/sharedInbox"),
|
||||
Bto: pub.ItemCollection{
|
||||
pub.IRI("http://example.com/sharedInbox"),
|
||||
},
|
||||
CC: ItemCollection{
|
||||
IRI("https://example.com/actors/ana"),
|
||||
IRI("https://example.com/actors/bob"),
|
||||
CC: pub.ItemCollection{
|
||||
pub.IRI("https://example.com/actors/ana"),
|
||||
pub.IRI("https://example.com/actors/bob"),
|
||||
},
|
||||
BCC: ItemCollection{
|
||||
IRI("https://darkside.cookie/actors/darthvader"),
|
||||
BCC: pub.ItemCollection{
|
||||
pub.IRI("https://darkside.cookie/actors/darthvader"),
|
||||
},
|
||||
},
|
||||
},
|
||||
"article_with_multiple_inreplyto": {
|
||||
expected: true,
|
||||
blank: &Article{},
|
||||
result: &Article{
|
||||
Type: ArticleType,
|
||||
ID: ObjectID("http://www.test.example/article/1"),
|
||||
Name: NaturalLanguageValues{
|
||||
blank: &pub.Article{},
|
||||
result: &pub.Article{
|
||||
Type: pub.ArticleType,
|
||||
ID: pub.ObjectID("http://www.test.example/article/1"),
|
||||
Name: pub.NaturalLanguageValues{
|
||||
{
|
||||
NilLangRef,
|
||||
pub.NilLangRef,
|
||||
"This someday will grow up to be an article",
|
||||
},
|
||||
},
|
||||
InReplyTo: ItemCollection{
|
||||
IRI("http://www.test.example/object/1"),
|
||||
IRI("http://www.test.example/object/778"),
|
||||
InReplyTo: pub.ItemCollection{
|
||||
pub.IRI("http://www.test.example/object/1"),
|
||||
pub.IRI("http://www.test.example/object/778"),
|
||||
},
|
||||
},
|
||||
},
|
Reference in a new issue