Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Jul 7, 2017
1 parent f9cecbd commit 9466b19
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 1 addition & 2 deletions backends/rapidpro/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ func (b *backend) PopNextOutgoingMsg() (*courier.Msg, error) {
}

// TODO: what other attributes are needed here?
msg := courier.NewOutgoingMsg(channel, dbMsg.ID, courier.NilMsgUUID, dbMsg.URN, dbMsg.Text)
msg.ExternalID = dbMsg.ExternalID
msg := courier.NewOutgoingMsg(channel, dbMsg.URN, dbMsg.Text).WithID(dbMsg.ID).WithExternalID(dbMsg.ExternalID)
msg.WorkerToken = token

return msg, nil
Expand Down
13 changes: 10 additions & 3 deletions msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func NewMsgUUID() MsgUUID {
// NewIncomingMsg creates a new message from the given params
func NewIncomingMsg(channel Channel, urn URN, text string) *Msg {
m := &Msg{}
m.ID = NilMsgID
m.UUID = NewMsgUUID()
m.Channel = channel
m.Text = text
Expand All @@ -78,10 +79,10 @@ func NewIncomingMsg(channel Channel, urn URN, text string) *Msg {
}

// NewOutgoingMsg creates a new message from the given params
func NewOutgoingMsg(channel Channel, id MsgID, uuid MsgUUID, urn URN, text string) *Msg {
func NewOutgoingMsg(channel Channel, urn URN, text string) *Msg {
m := &Msg{}
m.ID = id
m.UUID = uuid
m.ID = NilMsgID
m.UUID = NilMsgUUID
m.Channel = channel
m.Text = text
m.URN = urn
Expand Down Expand Up @@ -120,6 +121,12 @@ func (m *Msg) WithReceivedOn(date time.Time) *Msg { m.ReceivedOn = &date; return
// WithExternalID can be used to set the external id on a msg in a chained call
func (m *Msg) WithExternalID(id string) *Msg { m.ExternalID = id; return m }

// WithID can be used to set the id on a msg in a chained call
func (m *Msg) WithID(id MsgID) *Msg { m.ID = id; return m }

// WithUUID can be used to set the id on a msg in a chained call
func (m *Msg) WithUUID(uuid MsgUUID) *Msg { m.UUID = uuid; return m }

// AddAttachment can be used to append to the media urls for a message
func (m *Msg) AddAttachment(url string) *Msg { m.Attachments = append(m.Attachments, url); return m }

Expand Down

0 comments on commit 9466b19

Please sign in to comment.