Changes
3 changed files (+22/-7)
-
-
@@ -27,12 +27,10 @@ type Object struct {func GetAPSource(data []byte) Source { s := Source{} contBytes, _, _, err := jsonparser.Get(data, "source", "content") if err == nil { if contBytes, _, _, err := jsonparser.Get(data, "source", "content"); err == nil { s.Content.UnmarshalJSON(contBytes) } mimeBytes, _, _, err := jsonparser.Get(data, "source", "mimeType") if err == nil { if mimeBytes, _, _, err := jsonparser.Get(data, "source", "mediaType"); err == nil { s.MediaType.UnmarshalJSON(mimeBytes) }
-
-
-
@@ -1,6 +1,8 @@package activitypub import "testing" import ( "testing" ) func validateEmptyObject(o Object, t *testing.T) { if o.ID != "" {
-
@@ -60,3 +62,16 @@ func TestSource_UnmarshalJSON(t *testing.T) {s.UnmarshalJSON(dataEmpty) validateEmptySource(s, t) } func TestGetAPSource(t *testing.T) { data := []byte(`{"source": {"content": "test", "mediaType": "text/plain" }}`) a := GetAPSource(data) if a.Content.First() != "test" { t.Errorf("Content didn't match test value. Received %q, expecting %q", a.Content, "test") } if a.MediaType != "text/plain" { t.Errorf("Content didn't match test value. Received %q, expecting %q", a.MediaType, "text/plain") } }
-
-
-
@@ -227,6 +227,8 @@ func (l *LangRef) UnmarshalText(data []byte) error {func (n *NaturalLanguageValue) UnmarshalJSON(data []byte) error { val, typ, _, err := jsonparser.Get(data) if err != nil { // try our luck if data contains an unquoted string n.Append(NilLangRef, string(data)) return nil } switch typ {
-
@@ -418,9 +420,9 @@ type Relationship struct {type Tombstone struct { Parent // FormerType On a Tombstone object, the formerType property identifies the type of the object that was deleted. FormerType ActivityVocabularyType `jsonld:"formerType,omitempty"` FormerType ActivityVocabularyType `jsonld:"formerType,omitempty"` // Deleted On a Tombstone object, the deleted property is a timestamp for when the object was deleted. Deleted time.Time `jsonld:"deleted,omitempty"` Deleted time.Time `jsonld:"deleted,omitempty"` } // ValidGenericType validates the type against the valid generic object types
-