Changes
4 changed files (+20/-9)
-
-
@@ -1,10 +1,15 @@package jsonld import "encoding/json" import ( "encoding/json" "activitypub" ) type Ref string type Context struct { URL string URL Ref `json:"_"` Language activitypub.NaturalLanguageValue `json:"@language"` } func (c *Context) Ref() Ref {
-
@@ -15,5 +20,7 @@ func (r *Ref) MarshalText() ([]byte, error) {} func (c *Context) MarshalJSON() ([]byte, error) { return json.Marshal(getMap(c)) var a map[string]interface{} a = getMap(c) return json.Marshal(a) }
-
-
-
@@ -4,6 +4,7 @@ import ("bytes" "strings" "testing" "activitypub" ) func TestRef_MarshalText(t *testing.T) {
-
@@ -21,7 +22,7 @@ func TestRef_MarshalText(t *testing.T) {func TestContext_Ref(t *testing.T) { url := "test" c := Context{url} c := Context{URL: Ref(url)} if c.Ref() != Ref(url) { t.Errorf("Invalid result %#v, expected %#v", c.Ref(), Ref(url))
-
@@ -30,7 +31,9 @@ func TestContext_Ref(t *testing.T) {func TestContext_MarshalJSON(t *testing.T) { url := "test" c := Context{url} c := Context{URL: Ref(url)} c.Language = make(activitypub.NaturalLanguageValue, 1) c.Language["en"] = "en-GB" out, err := c.MarshalJSON() if err != nil {
-
@@ -39,4 +42,5 @@ func TestContext_MarshalJSON(t *testing.T) {if !strings.Contains(string(out), url) { t.Errorf("Json doesn't contain %#v, %#v", url, string(out)) } t.Logf("%s", out) }
-
-
-
@@ -25,7 +25,7 @@ func TestMarshal(t *testing.T) {b := mockTypeA{} url := "http://www.habarnam.ro" c := Context{URL: url} c := Context{URL: Ref(url)} var err error var out []byte
-
@@ -110,8 +110,8 @@ func TestIsEmpty(t *testing.T) {} func TestPayloadWithContext_MarshalJSON(t *testing.T) { t.SkipNow() t.Skipf("Not implemented") } func TestPayloadWithContext_UnmarshalJSON(t *testing.T) { t.SkipNow() t.Skipf("Not implemented") }
-
-
-
@@ -27,7 +27,7 @@ func TestCreateActivityHTTPSerialization(t *testing.T) {baseUri := string(activitypub.ActivityBaseURI) c := jsonld.Context{ URL: baseUri + o.Type, URL: jsonld.Ref(baseUri + o.Type), } out, err := jsonld.Marshal(o, &c)
-