This repository has been archived on 2022-11-27. You can view files and clone it, but cannot push or open issues or pull requests.
activitypub/tests/integration_test.go

43 lines
895 B
Go
Raw Normal View History

2017-10-01 12:44:49 +00:00
package tests
import (
"activitypub"
"jsonld"
2017-10-01 13:04:51 +00:00
"testing"
2017-10-01 12:44:49 +00:00
)
2017-10-01 12:55:20 +00:00
func TestAcceptSerialization(t *testing.T) {
2017-10-01 12:44:49 +00:00
o := activitypub.AcceptNew("https://localhost/myactivity")
o.Name = make(activitypub.NaturalLanguageValue, 1)
o.Name["en"] = "test"
2017-10-01 13:04:51 +00:00
ctx := jsonld.Context{URL: "https://www.w3.org/ns/activitystreams"}
2017-10-01 12:44:49 +00:00
bytes, err := jsonld.Marshal(o, &ctx)
if err != nil {
t.Errorf("Error: %v", err)
}
t.Logf("%s", bytes)
}
2017-10-01 13:04:51 +00:00
func TestCreateActivityHTTPSerialization(t *testing.T) {
id := activitypub.ObjectId("test_object")
o := activitypub.AcceptNew(id)
o.Name["en"] = "Accept New"
baseUri := string(activitypub.ActivityBaseURI)
c := jsonld.Context{
URL: jsonld.Ref(baseUri + string(o.Type)),
2017-10-01 13:04:51 +00:00
}
out, err := jsonld.Marshal(o, &c)
if err != nil {
t.Error(err)
}
outNoC, errNoC := jsonld.Marshal(o, nil)
if errNoC != nil {
t.Error(errNoC)
}
t.Logf("%s\n\n%s", out, outNoC)
2017-10-01 13:04:51 +00:00
}