Test changes
This commit is contained in:
@@ -47,7 +47,7 @@ func ResetTestDB(t *testing.T, tableName string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestContact(id uuid.UUID, userId uuid.UUID) contact.Contact {
|
func ContactTest(id uuid.UUID, userId uuid.UUID) contact.Contact {
|
||||||
if id == uuid.Nil {
|
if id == uuid.Nil {
|
||||||
id = uuid.New()
|
id = uuid.New()
|
||||||
return contact.Contact{Id: &id, PhoneNumber: "+10123456789", UserId: &userId}
|
return contact.Contact{Id: &id, PhoneNumber: "+10123456789", UserId: &userId}
|
||||||
@@ -56,15 +56,16 @@ func TestContact(id uuid.UUID, userId uuid.UUID) contact.Contact {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMessage(id uuid.UUID, userId uuid.UUID) message.Message {
|
func MessageTest(id uuid.UUID, userId uuid.UUID) message.Message {
|
||||||
if id == uuid.Nil {
|
if id == uuid.Nil {
|
||||||
return message.Message{Id: uuid.New(), Content: "Oh how the mighty have fallen", UserId: userId}
|
id = uuid.New()
|
||||||
|
return message.Message{Id: &id, Content: "Oh how the mighty have fallen", UserId: &userId}
|
||||||
} else {
|
} else {
|
||||||
return message.Message{Id: id, Content: "Oh how the mighty have fallen", UserId: userId}
|
return message.Message{Id: &id, Content: "Oh how the mighty have fallen", UserId: &userId}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestScheduledMessage(id uuid.UUID, userId uuid.UUID, now time.Time) scheduling.ScheduledMessage {
|
func ScheduledMessageTest(id uuid.UUID, userId uuid.UUID, now time.Time) scheduling.ScheduledMessage {
|
||||||
if id == uuid.Nil {
|
if id == uuid.Nil {
|
||||||
return scheduling.ScheduledMessage{Id: uuid.New(), UserId: userId, Scheduled: now.Add(20 * time.Minute), Status: scheduling.Pending}
|
return scheduling.ScheduledMessage{Id: uuid.New(), UserId: userId, Scheduled: now.Add(20 * time.Minute), Status: scheduling.Pending}
|
||||||
} else {
|
} else {
|
||||||
@@ -72,11 +73,11 @@ func TestScheduledMessage(id uuid.UUID, userId uuid.UUID, now time.Time) schedul
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestScheduledMessageEvent(messageId, contactId, scheduledMessageId uuid.UUID) scheduling.ScheduledMessageEvent {
|
func ScheduledMessageEventTest(messageId, contactId, scheduledMessageId uuid.UUID) scheduling.ScheduledMessageEvent {
|
||||||
return scheduling.ScheduledMessageEvent{MessageId: messageId, ContactId: contactId, ScheduledMessageId: scheduledMessageId}
|
return scheduling.ScheduledMessageEvent{MessageId: messageId, ContactId: contactId, ScheduledMessageId: scheduledMessageId}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMERResponseInString() string {
|
func MERResponseInString() string {
|
||||||
return `{
|
return `{
|
||||||
"body": "Whoknows?",
|
"body": "Whoknows?",
|
||||||
"num_segments": "0",
|
"num_segments": "0",
|
||||||
@@ -98,7 +99,7 @@ func TestMERResponseInString() string {
|
|||||||
}`
|
}`
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestConvertStringToMapOfAny(response string) (map[string]any, error) {
|
func ConvertStringToMapOfAny(response string) (map[string]any, error) {
|
||||||
bytes := []byte(response)
|
bytes := []byte(response)
|
||||||
var merResponse map[string]any
|
var merResponse map[string]any
|
||||||
err := json.Unmarshal(bytes, &merResponse)
|
err := json.Unmarshal(bytes, &merResponse)
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ func TestRecordMessageEventResponseWithMock(t *testing.T) {
|
|||||||
scheduledMessageId := uuid.New()
|
scheduledMessageId := uuid.New()
|
||||||
testUserId := uuid.New()
|
testUserId := uuid.New()
|
||||||
|
|
||||||
con := TestContact(contactId, testUserId)
|
con := ContactTest(contactId, testUserId)
|
||||||
msg := TestMessage(messageId, testUserId)
|
msg := MessageTest(messageId, testUserId)
|
||||||
schMsg := TestScheduledMessage(scheduledMessageId, testUserId, now)
|
schMsg := ScheduledMessageTest(scheduledMessageId, testUserId, now)
|
||||||
event := scheduling.ScheduledMessageEvent{}
|
event := scheduling.ScheduledMessageEvent{}
|
||||||
|
|
||||||
ctx := t.Context()
|
ctx := t.Context()
|
||||||
@@ -104,9 +104,9 @@ func TestGetMessageEventResponse(t *testing.T) {
|
|||||||
scheduledMessageId := uuid.New()
|
scheduledMessageId := uuid.New()
|
||||||
testUserId := uuid.New()
|
testUserId := uuid.New()
|
||||||
|
|
||||||
con := TestContact(contactId, testUserId)
|
con := ContactTest(contactId, testUserId)
|
||||||
msg := TestMessage(messageId, testUserId)
|
msg := MessageTest(messageId, testUserId)
|
||||||
schMsg := TestScheduledMessage(scheduledMessageId, testUserId, now)
|
schMsg := ScheduledMessageTest(scheduledMessageId, testUserId, now)
|
||||||
event := scheduling.ScheduledMessageEvent{}
|
event := scheduling.ScheduledMessageEvent{}
|
||||||
|
|
||||||
ctx := t.Context()
|
ctx := t.Context()
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ func TestGetMessageWithMock(t *testing.T) {
|
|||||||
mockstore := mock.NewMockMessageStore()
|
mockstore := mock.NewMockMessageStore()
|
||||||
testUserId := uuid.New()
|
testUserId := uuid.New()
|
||||||
|
|
||||||
testCon := message.Message{Content: "Who is the one that benefits?", UserId: testUserId}
|
testCon := message.Message{Content: "Who is the one that benefits?", UserId: &testUserId}
|
||||||
ctx := t.Context()
|
ctx := t.Context()
|
||||||
if err := mockstore.CreateMessage(ctx, &testCon); err != nil {
|
if err := mockstore.CreateMessage(ctx, &testCon); err != nil {
|
||||||
assert.NoError(t, err, "Error creating message")
|
assert.NoError(t, err, "Error creating message")
|
||||||
|
|||||||
@@ -24,15 +24,15 @@ func TestUpdateScheduledMessageStatusWithMock(t *testing.T) {
|
|||||||
messageStore := mock.NewMockMessageStore()
|
messageStore := mock.NewMockMessageStore()
|
||||||
schMsgStore := mock.NewMockScheduledMessageStore()
|
schMsgStore := mock.NewMockScheduledMessageStore()
|
||||||
|
|
||||||
recipientId := uuid.New()
|
contactId := uuid.New()
|
||||||
messageId := uuid.New()
|
messageId := uuid.New()
|
||||||
scheduledMessageId := uuid.New()
|
scheduledMessageId := uuid.New()
|
||||||
testUserId := uuid.New()
|
testUserId := uuid.New()
|
||||||
|
|
||||||
con := TestContact(recipientId, testUserId)
|
con := ContactTest(contactId, testUserId)
|
||||||
msg := TestMessage(messageId, testUserId)
|
msg := MessageTest(messageId, testUserId)
|
||||||
schMsg := TestScheduledMessage(scheduledMessageId, testUserId, now)
|
schMsg := ScheduledMessageTest(scheduledMessageId, testUserId, now)
|
||||||
event := TestScheduledMessageEvent(msg.Id, *con.Id, schMsg.Id)
|
event := ScheduledMessageEventTest(*msg.Id, *con.Id, schMsg.Id)
|
||||||
|
|
||||||
ctx := t.Context()
|
ctx := t.Context()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user