Skip to content

Commit

Permalink
Adding deleted to a delete messages payload
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-stanchev committed Sep 12, 2022
1 parent 0331e15 commit 20437d4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func (m *relatedContentMapper) mapRelatedContent() ([]byte, string, error) {
if len(relatedItems) > 0 {
cc = m.newContentCollection(contentCollectionUUID, relatedItems)
}
} else {
cc.Deleted = true
}

mc := m.newMappedContent(contentCollectionUUID, cc)
Expand Down
9 changes: 6 additions & 3 deletions mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ func TestMapNextVideoRelatedContentHappyFlows(t *testing.T) {
}{
{
"next-video-input.json",
newStringMappedContent(t, "c4cde316-128c-11e7-80f4-13e067d5072c", "", ""),
newStringMappedContent(t, "c4cde316-128c-11e7-80f4-13e067d5072c", "", "", false),
testVideoUUID,
false,
},
{
"next-video-delete-input.json",
newStringMappedContent(t, "", "", ""),
newStringMappedContent(t, "", "", "", true),
testVideoUUID,
false,
},
Expand Down Expand Up @@ -238,7 +238,7 @@ func newRelatedItem(id interface{}) map[string]interface{} {
return obj
}

func newStringMappedContent(t *testing.T, itemUUID string, tid string, msgDate string) string {
func newStringMappedContent(t *testing.T, itemUUID string, tid string, msgDate string, deletePayload bool) string {
var cc ContentCollection
if itemUUID != "" {
items := []Item{{itemUUID}}
Expand All @@ -250,6 +250,9 @@ func newStringMappedContent(t *testing.T, itemUUID string, tid string, msgDate s
CollectionType: collectionType,
}
}
if deletePayload {
cc.Deleted = true
}

mc := MappedContent{
Payload: cc,
Expand Down
1 change: 1 addition & 0 deletions model.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type ContentCollection struct {
PublishReference string `json:"publishReference,omitempty"`
LastModified string `json:"lastModified,omitempty"`
CollectionType string `json:"type,omitempty"`
Deleted bool `json:"delete,omitempty"`
}

// Item within content collection
Expand Down
4 changes: 2 additions & 2 deletions queuehandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestQueueConsume(t *testing.T) {
"application/json",
"1234",
true,
newStringMappedContent(t, "c4cde316-128c-11e7-80f4-13e067d5072c", "1234", lastModified),
newStringMappedContent(t, "c4cde316-128c-11e7-80f4-13e067d5072c", "1234", lastModified, false),
},
{
"next-video-input.json",
Expand Down Expand Up @@ -72,7 +72,7 @@ func TestQueueConsume(t *testing.T) {
"application/json",
"1234",
true,
newStringMappedContent(t, "", "1234", lastModified),
newStringMappedContent(t, "", "1234", lastModified, false),
},
{
"next-video-empty-related-input.json",
Expand Down
2 changes: 1 addition & 1 deletion servicehandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestMapRequest(t *testing.T) {
}{
{
"next-video-input.json",
newStringMappedContent(t, "c4cde316-128c-11e7-80f4-13e067d5072c", "", ""),
newStringMappedContent(t, "c4cde316-128c-11e7-80f4-13e067d5072c", "", "", false),
http.StatusOK,
},
{
Expand Down

0 comments on commit 20437d4

Please sign in to comment.