Fixed errors resulting from using local Object types

This commit is contained in:
Marius Orcsik 2019-09-24 10:05:14 +03:00
parent 0ff0c8c86f
commit c69bcfeaeb
No known key found for this signature in database
GPG key ID: 889CE8E4FB2D877A

View file

@ -202,13 +202,13 @@ var allTests = tests{
"object_with_url": testPair{
expected: true,
blank: &ap.Object{},
result: &ap.Object{Parent: a.Object{URL: a.IRI("http://littr.git/api/accounts/system")}},
result: &ap.Object{Parent: a.Parent{URL: a.IRI("http://littr.git/api/accounts/system")}},
},
"object_with_url_collection": testPair{
expected: true,
blank: &ap.Object{},
result: &ap.Object{
Parent: a.Object{
Parent: a.Parent{
URL: a.ItemCollection{
a.IRI("http://littr.git/api/accounts/system"),
a.IRI("http://littr.git/~system"),
@ -220,12 +220,13 @@ var allTests = tests{
expected: true,
blank: &ap.Object{},
result: &ap.Object{
Parent: a.Object{
Parent: a.Parent{
Type: a.ObjectType,
ID: a.ObjectID("http://www.test.example/object/1"),
Name: a.NaturalLanguageValues{{
a.NilLangRef, "A Simple, non-specific object",
}},
},
},
},
},
},
@ -240,14 +241,12 @@ var allTests = tests{
a.NilLangRef, "A Simple, non-specific object",
}},
Tag: a.ItemCollection{
&ap.Object{
Parent: a.Parent {
&a.Object{
Name: a.NaturalLanguageValues{{
a.NilLangRef, "#my_tag",
}},
ID: a.ObjectID("http://example.com/tag/my_tag"),
},
},
&a.Mention{
Name: a.NaturalLanguageValues{{
a.NilLangRef, "@ana",
@ -263,7 +262,7 @@ var allTests = tests{
expected: true,
blank: &ap.Object{},
result: &ap.Object{
Parent: a.Object{
Parent: a.Parent{
Type: a.ObjectType,
ID: a.ObjectID("http://www.test.example/object/1"),
Replies: &a.Collection{
@ -273,7 +272,8 @@ var allTests = tests{
},
TotalItems: 1,
Items: a.ItemCollection{
&a.Object{
&ap.Object{
Parent: a.Parent{
ID: a.ObjectID("http://www.test.example/object/1/replies/2"),
Type: a.ArticleType,
Name: a.NaturalLanguageValues{{a.NilLangRef, "Example title"}},
@ -283,6 +283,7 @@ var allTests = tests{
},
},
},
},
"person_with_outbox": testPair{
expected: true,
blank: &ap.Person{},
@ -314,7 +315,8 @@ var allTests = tests{
},
TotalItems: 1,
OrderedItems: a.ItemCollection{
&a.Object{
&ap.Object{
Parent: a.Parent{
ID: a.ObjectID("http://example.com/outbox/53c6fb47"),
Type: a.ArticleType,
Name: a.NaturalLanguageValues{{a.NilLangRef, "Example title"}},
@ -328,6 +330,7 @@ var allTests = tests{
},
},
},
},
"ordered_collection_page": testPair{
expected: true,
blank: &a.OrderedCollectionPage{},
@ -344,7 +347,8 @@ var allTests = tests{
Current: a.IRI("http://example.com/outbox?page=2"),
TotalItems: 1,
OrderedItems: a.ItemCollection{
&a.Object{
&ap.Object{
Parent: a.Parent{
ID: a.ObjectID("http://example.com/outbox/53c6fb47"),
Type: a.ArticleType,
Name: a.NaturalLanguageValues{{a.NilLangRef, "Example title"}},
@ -359,6 +363,7 @@ var allTests = tests{
},
},
},
},
"natural_language_values": {
expected: true,
blank: &a.NaturalLanguageValues{},
@ -380,15 +385,17 @@ var allTests = tests{
Type: a.CreateType,
},
Actor: a.IRI("https://littr.git/api/accounts/anonymous"),
Object: &a.Object{
Object: &ap.Object{
Parent: a.Parent{
Type: a.NoteType,
AttributedTo: a.IRI("https://littr.git/api/accounts/anonymous"),
InReplyTo: a.IRI("https://littr.git/api/accounts/system/outbox/7ca154ff"),
InReplyTo: a.ItemCollection{a.IRI("https://littr.git/api/accounts/system/outbox/7ca154ff")},
Content: a.NaturalLanguageValues{{a.NilLangRef, "<p>Hello world</p>"}},
To: a.ItemCollection{a.IRI("https://www.w3.org/ns/activitystreams#Public")},
},
},
},
},
"like_activity_with_iri_actor": {
expected: true,
blank: &a.Like{},
@ -398,17 +405,19 @@ var allTests = tests{
Published: time.Date(2018, time.September, 6, 15, 15, 9, 0, zLoc),
},
Actor: a.IRI("https://littr.git/api/accounts/24d4b96f"),
Object: &a.Article{
Object: &ap.Object{
Parent: a.Article{
ID: a.ObjectID("https://littr.git/api/accounts/ana/liked/7ca154ff"),
Type: a.ArticleType,
},
},
},
},
"object_with_audience": testPair{
expected: true,
blank: &ap.Object{},
result: &ap.Object{
Parent: a.Object{
Parent: a.Parent{
Type: a.ObjectType,
ID: a.ObjectID("http://www.test.example/object/1"),
To: a.ItemCollection{
@ -447,7 +456,7 @@ func getFileContents(path string) ([]byte, error) {
return data, nil
}
func Test_ActivityPubUnmarshall(t *testing.T) {
func Test_ActivityPubUnmarshal(t *testing.T) {
var err error
var f = t.Errorf