Skip to content

Commit

Permalink
Adding deleted field to delete payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-stanchev committed Sep 12, 2022
1 parent c4f8a13 commit 255f13f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions video/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type videoPayload struct {
CanonicalWebURL string `json:"canonicalWebUrl,omitempty"`
AlternativeTitles *alternativeTitles `json:"alternativeTitles,omitempty"`
AlternativeStandfirst *alternativeStandfirsts `json:"alternativeStandfirsts,omitempty"`
Deleted bool `json:"deleted,omitempty"`
}

type caption struct {
Expand Down
7 changes: 6 additions & 1 deletion video/video_mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ func (v VideoMapper) TransformMsg(m kafka.FTMessage) (kafka.FTMessage, string, e
}

contentURI := utils.GetPrefixedURL(videoContentURIBase, uuid)
videoModel := &videoPayload{}

videoModel := &videoPayload{
ID: uuid,
Deleted: true,
}

deleteVideoMsg, err := v.buildAndMarshalPublicationEvent(videoModel, contentURI, lastModified, tid)
return deleteVideoMsg, uuid, err
}
Expand Down
2 changes: 1 addition & 1 deletion video/video_mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestTransformMsg_UnpublishEvent(t *testing.T) {
resultMsg, uuid, err := mapper.TransformMsg(message)
assert.NoError(t, err, "Error not expected for unpublish event")
assert.Equal(t, "bad50c54-76d9-30e9-8734-b999c708aa4c", uuid, "UUID not extracted correctly from unpublish event")
assert.Equal(t, "{\"contentUri\":\"http://next-video-mapper.svc.ft.com/video/model/bad50c54-76d9-30e9-8734-b999c708aa4c\",\"payload\":{},\"lastModified\":\"2017-04-13T10:27:32.353Z\"}", resultMsg.Body)
assert.Equal(t, "{\"contentUri\":\"http://next-video-mapper.svc.ft.com/video/model/bad50c54-76d9-30e9-8734-b999c708aa4c\",\"payload\":{\"uuid\":\"bad50c54-76d9-30e9-8734-b999c708aa4c\",\"deleted\":true},\"lastModified\":\"2017-04-13T10:27:32.353Z\"}", resultMsg.Body)
}

func TestTransformMsg_Success(t *testing.T) {
Expand Down

0 comments on commit 255f13f

Please sign in to comment.