Changes
7 changed files (+273/-17)
-
-
@@ -307,16 +307,3 @@ func (o *OrderedCollection) MarshalJSON() ([]byte, error) {return nil, nil } */ // Append adds an element to an OutboxStream func (o *OutboxStream) Append(ob ObjectOrLink) error { o.OrderedItems = append(o.OrderedItems, ob) o.TotalItems++ return nil } // Append adds an element to an Outbox func (o *Outbox) Append(ob ObjectOrLink) error { o.OrderedItems = append(o.OrderedItems, ob) o.TotalItems++ return nil }
-
-
-
@@ -33,9 +33,16 @@ func (i *InboxStream) Append(o ObjectOrLink) error {return nil } // Append adds an element to an Inbox func (o *Inbox) Append(ob ObjectOrLink) error { o.OrderedItems = append(o.OrderedItems, ob) o.TotalItems++ return nil } func (i InboxStream) GetID() ObjectID { return i.ID } func (i InboxStream)GetType() ActivityVocabularyType { func (i InboxStream) GetType() ActivityVocabularyType { return i.Type }
-
-
-
@@ -0,0 +1,79 @@package activitypub import ( "reflect" "testing" ) func TestInboxNew(t *testing.T) { i := InboxNew() id := ObjectID("inbox") if i.ID != id { t.Errorf("%T should be initialized with %q as %T", i, id, id) } if len(i.Name) != 0 { t.Errorf("%T should be initialized with 0 length Name", i) } if len(i.Content) != 0 { t.Errorf("%T should be initialized with 0 length Content", i) } if len(i.Summary) != 0 { t.Errorf("%T should be initialized with 0 length Summary", i) } if i.TotalItems != 0 { t.Errorf("%T should be initialized with 0 TotalItems", i) } } func TestInboxStream_GetID(t *testing.T) { o := InboxStream{} if o.GetID() != "" { t.Errorf("%T should be initialized with empty %T", o, o.GetID()) } id := ObjectID("test_out_stream") o.ID = id if o.GetID() != id { t.Errorf("%T should have %T as %q", o, id, id) } } func TestInboxStream_GetType(t *testing.T) { o := InboxStream{} if o.GetType() != "" { t.Errorf("%T should be initialized with empty %T", o, o.GetType()) } o.Type = OrderedCollectionType if o.GetType() != OrderedCollectionType { t.Errorf("%T should have %T as %q", o, o.GetType(), OrderedCollectionType) } } func TestInboxStream_Append(t *testing.T) { o := InboxStream{} val := Object{ID: ObjectID("grrr")} o.Append(val) if o.TotalItems != 1 { t.Errorf("%T should have exactly an element, found %d", o, o.TotalItems) } if !reflect.DeepEqual(o.OrderedItems[0], val) { t.Errorf("First item in %T.%T does not match %q", o, o.OrderedItems, val.ID) } } func TestInbox_Append(t *testing.T) { i := InboxNew() val := Object{ID: ObjectID("grrr")} i.Append(val) if i.TotalItems != 1 { t.Errorf("%T should have exactly an element, found %d", i, i.TotalItems) } if !reflect.DeepEqual(i.OrderedItems[0], val) { t.Errorf("First item in %T.%T does not match %q", i, i.OrderedItems, val.ID) } }
-
-
-
@@ -11,7 +11,6 @@ type (Liked OrderedCollection ) // LikedCollection initializes a new Outbox func LikedNew() *Liked { id := ObjectID("liked")
-
@@ -25,6 +24,7 @@ func LikedNew() *Liked {return &l } // Append adds an element to an LikedCollection func (l *LikedCollection) Append(o ObjectOrLink) error { l.OrderedItems = append(l.OrderedItems, o)
-
@@ -32,9 +32,16 @@ func (l *LikedCollection) Append(o ObjectOrLink) error {return nil } // Append adds an element to an Outbox func (l *Liked) Append(ob ObjectOrLink) error { l.OrderedItems = append(l.OrderedItems, ob) l.TotalItems++ return nil } func (l LikedCollection) GetID() ObjectID { return l.ID } func (l LikedCollection)GetType() ActivityVocabularyType { func (l LikedCollection) GetType() ActivityVocabularyType { return l.Type }
-
-
-
@@ -0,0 +1,80 @@package activitypub import ( "reflect" "testing" ) func TestLikedNew(t *testing.T) { l := LikedNew() id := ObjectID("liked") if l.ID != id { t.Errorf("%T should be initialized with %q as %T", l, id, id) } if len(l.Name) != 0 { t.Errorf("%T should be initialized with 0 length Name", l) } if len(l.Content) != 0 { t.Errorf("%T should be initialized with 0 length Content", l) } if len(l.Summary) != 0 { t.Errorf("%T should be initialized with 0 length Summary", l) } if l.TotalItems != 0 { t.Errorf("%T should be initialized with 0 TotalItems", l) } } func TestLikedCollection_GetID(t *testing.T) { l := LikedCollection{} if l.GetID() != "" { t.Errorf("%T should be initialized with empty %T", l, l.GetID()) } id := ObjectID("test_out_stream") l.ID = id if l.GetID() != id { t.Errorf("%T should have %T as %q", l, id, id) } } func TestLikedCollection_GetType(t *testing.T) { l := LikedCollection{} if l.GetType() != "" { t.Errorf("%T should be initialized with empty %T", l, l.GetType()) } l.Type = OrderedCollectionType if l.GetType() != OrderedCollectionType { t.Errorf("%T should have %T as %q", l, l.GetType(), OrderedCollectionType) } } func TestLikedCollection_Append(t *testing.T) { l := LikedCollection{} val := Object{ID: ObjectID("grrr")} l.Append(val) if l.TotalItems != 1 { t.Errorf("%T should have exactly an element, found %d", l, l.TotalItems) } if !reflect.DeepEqual(l.OrderedItems[0], val) { t.Errorf("First item in %T.%T does not match %q", l, l.OrderedItems, val.ID) } } func TestLiked_Append(t *testing.T) { l := LikedNew() val := Object{ID: ObjectID("grrr")} l.Append(val) if l.TotalItems != 1 { t.Errorf("%T should have exactly an element, found %d", l, l.TotalItems) } if !reflect.DeepEqual(l.OrderedItems[0], val) { t.Errorf("First item in %T.%T does not match %q", l, l.OrderedItems, val.ID) } }
-
-
-
@@ -23,9 +23,25 @@ func OutboxNew() *Outbox {return &i } // Append adds an element to an OutboxStream func (o *OutboxStream) Append(ob ObjectOrLink) error { o.OrderedItems = append(o.OrderedItems, ob) o.TotalItems++ return nil } // Append adds an element to an Outbox func (o *Outbox) Append(ob ObjectOrLink) error { o.OrderedItems = append(o.OrderedItems, ob) o.TotalItems++ return nil } func (o OutboxStream) GetID() ObjectID { return o.ID } func (o OutboxStream)GetType() ActivityVocabularyType { func (o OutboxStream) GetType() ActivityVocabularyType { return o.Type }
-
-
-
@@ -0,0 +1,80 @@package activitypub import ( "reflect" "testing" ) func TestOutboxNew(t *testing.T) { o := OutboxNew() id := ObjectID("outbox") if o.ID != id { t.Errorf("%T should be initialized with %q as %T", o, id, id) } if len(o.Name) != 0 { t.Errorf("%T should be initialized with 0 length Name", o) } if len(o.Content) != 0 { t.Errorf("%T should be initialized with 0 length Content", o) } if len(o.Summary) != 0 { t.Errorf("%T should be initialized with 0 length Summary", o) } if o.TotalItems != 0 { t.Errorf("%T should be initialized with 0 TotalItems", o) } } func TestOutboxStream_GetID(t *testing.T) { o := OutboxStream{} if o.GetID() != "" { t.Errorf("%T should be initialized with empty %T", o, o.GetID()) } id := ObjectID("test_out_stream") o.ID = id if o.GetID() != id { t.Errorf("%T should have %T as %q", o, id, id) } } func TestOutboxStream_GetType(t *testing.T) { o := OutboxStream{} if o.GetType() != "" { t.Errorf("%T should be initialized with empty %T", o, o.GetType()) } o.Type = OrderedCollectionType if o.GetType() != OrderedCollectionType { t.Errorf("%T should have %T as %q", o, o.GetType(), OrderedCollectionType) } } func TestOutboxStream_Append(t *testing.T) { o := OutboxStream{} val := Object{ID: ObjectID("grrr")} o.Append(val) if o.TotalItems != 1 { t.Errorf("%T should have exactly an element, found %d", o, o.TotalItems) } if !reflect.DeepEqual(o.OrderedItems[0], val) { t.Errorf("First item in %T.%T does not match %q", o, o.OrderedItems, val.ID) } } func TestOutbox_Append(t *testing.T) { o := OutboxNew() val := Object{ID: ObjectID("grrr")} o.Append(val) if o.TotalItems != 1 { t.Errorf("%T should have exactly an element, found %d", o, o.TotalItems) } if !reflect.DeepEqual(o.OrderedItems[0], val) { t.Errorf("First item in %T.%T does not match %q", o, o.OrderedItems, val.ID) } }
-