Don't increment TotalItems when appending items
This commit is contained in:
parent
a8cd8b42ca
commit
3cde24f465
2 changed files with 13 additions and 19 deletions
|
@ -126,28 +126,24 @@ func OrderedCollectionPageNew(parent CollectionInterface) *OrderedCollectionPage
|
|||
// Append adds an element to an OrderedCollection
|
||||
func (o *OrderedCollection) Append(ob Item) error {
|
||||
o.OrderedItems = append(o.OrderedItems, ob)
|
||||
o.TotalItems++
|
||||
return nil
|
||||
}
|
||||
|
||||
// Append adds an element to a Collection
|
||||
func (c *Collection) Append(ob Item) error {
|
||||
c.Items = append(c.Items, ob)
|
||||
c.TotalItems++
|
||||
return nil
|
||||
}
|
||||
|
||||
// Append adds an element to an OrderedCollectionPage
|
||||
func (o *OrderedCollectionPage) Append(ob Item) error {
|
||||
o.OrderedItems = append(o.OrderedItems, ob)
|
||||
o.TotalItems++
|
||||
return nil
|
||||
}
|
||||
|
||||
// Append adds an element to a CollectionPage
|
||||
func (c *CollectionPage) Append(ob Item) error {
|
||||
c.Items = append(c.Items, ob)
|
||||
c.TotalItems++
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -65,9 +65,9 @@ func Test_OrderedCollection_Append(t *testing.T) {
|
|||
c := OrderedCollectionNew(id)
|
||||
c.Append(val)
|
||||
|
||||
if c.TotalItems != 1 {
|
||||
t.Errorf("Inbox collection of %q should have one element", *c.GetID())
|
||||
}
|
||||
//if c.TotalItems != 1 {
|
||||
// t.Errorf("Inbox collection of %q should have one element", *c.GetID())
|
||||
//}
|
||||
if !reflect.DeepEqual(c.OrderedItems[0], val) {
|
||||
t.Errorf("First item in Inbox is does not match %q", val.ID)
|
||||
}
|
||||
|
@ -81,9 +81,9 @@ func TestCollection_Append(t *testing.T) {
|
|||
c := CollectionNew(id)
|
||||
c.Append(val)
|
||||
|
||||
if c.TotalItems != 1 {
|
||||
t.Errorf("Inbox collection of %q should have one element", *c.GetID())
|
||||
}
|
||||
//if c.TotalItems != 1 {
|
||||
// t.Errorf("Inbox collection of %q should have one element", *c.GetID())
|
||||
//}
|
||||
if !reflect.DeepEqual(c.Items[0], val) {
|
||||
t.Errorf("First item in Inbox is does not match %q", val.ID)
|
||||
}
|
||||
|
@ -102,9 +102,9 @@ func TestCollectionPage_Append(t *testing.T) {
|
|||
if p.PartOf != c.GetLink() {
|
||||
t.Errorf("Collection page should point to collection %q", c.GetLink())
|
||||
}
|
||||
if p.TotalItems != 1 {
|
||||
t.Errorf("Collection page of %q should have exactly one element", *p.GetID())
|
||||
}
|
||||
//if p.TotalItems != 1 {
|
||||
// t.Errorf("Collection page of %q should have exactly one element", *p.GetID())
|
||||
//}
|
||||
if !reflect.DeepEqual(p.Items[0], val) {
|
||||
t.Errorf("First item in Inbox is does not match %q", val.ID)
|
||||
}
|
||||
|
@ -288,9 +288,9 @@ func TestOrderedCollection_Append(t *testing.T) {
|
|||
if p.PartOf != c.GetLink() {
|
||||
t.Errorf("Ordereed collection page should point to ordered collection %q", c.GetLink())
|
||||
}
|
||||
if p.TotalItems != 1 {
|
||||
t.Errorf("Ordered collection page of %q should have exactly one element", *p.GetID())
|
||||
}
|
||||
//if p.TotalItems != 1 {
|
||||
// t.Errorf("Ordered collection page of %q should have exactly one element", *p.GetID())
|
||||
//}
|
||||
if !reflect.DeepEqual(p.OrderedItems[0], val) {
|
||||
t.Errorf("First item in Inbox is does not match %q", val.ID)
|
||||
}
|
||||
|
@ -474,9 +474,7 @@ func TestOrderedCollectionPage_Append(t *testing.T) {
|
|||
if p.PartOf != c.GetLink() {
|
||||
t.Errorf("OrderedCollection page should point to OrderedCollection %q", c.GetLink())
|
||||
}
|
||||
if p.TotalItems != 1 {
|
||||
t.Errorf("OrderedCollection page of %q should have exactly one element", *p.GetID())
|
||||
}
|
||||
//a
|
||||
if !reflect.DeepEqual(p.OrderedItems[0], val) {
|
||||
t.Errorf("First item in Inbox is does not match %q", val.ID)
|
||||
}
|
||||
|
|
Reference in a new issue