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 {
|
||||
id = uuid.New()
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
return scheduling.ScheduledMessage{Id: uuid.New(), UserId: userId, Scheduled: now.Add(20 * time.Minute), Status: scheduling.Pending}
|
||||
} 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}
|
||||
}
|
||||
|
||||
func TestMERResponseInString() string {
|
||||
func MERResponseInString() string {
|
||||
return `{
|
||||
"body": "Whoknows?",
|
||||
"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)
|
||||
var merResponse map[string]any
|
||||
err := json.Unmarshal(bytes, &merResponse)
|
||||
|
||||
@@ -36,9 +36,9 @@ func TestRecordMessageEventResponseWithMock(t *testing.T) {
|
||||
scheduledMessageId := uuid.New()
|
||||
testUserId := uuid.New()
|
||||
|
||||
con := TestContact(contactId, testUserId)
|
||||
msg := TestMessage(messageId, testUserId)
|
||||
schMsg := TestScheduledMessage(scheduledMessageId, testUserId, now)
|
||||
con := ContactTest(contactId, testUserId)
|
||||
msg := MessageTest(messageId, testUserId)
|
||||
schMsg := ScheduledMessageTest(scheduledMessageId, testUserId, now)
|
||||
event := scheduling.ScheduledMessageEvent{}
|
||||
|
||||
ctx := t.Context()
|
||||
@@ -104,9 +104,9 @@ func TestGetMessageEventResponse(t *testing.T) {
|
||||
scheduledMessageId := uuid.New()
|
||||
testUserId := uuid.New()
|
||||
|
||||
con := TestContact(contactId, testUserId)
|
||||
msg := TestMessage(messageId, testUserId)
|
||||
schMsg := TestScheduledMessage(scheduledMessageId, testUserId, now)
|
||||
con := ContactTest(contactId, testUserId)
|
||||
msg := MessageTest(messageId, testUserId)
|
||||
schMsg := ScheduledMessageTest(scheduledMessageId, testUserId, now)
|
||||
event := scheduling.ScheduledMessageEvent{}
|
||||
|
||||
ctx := t.Context()
|
||||
|
||||
@@ -51,7 +51,7 @@ func TestGetMessageWithMock(t *testing.T) {
|
||||
mockstore := mock.NewMockMessageStore()
|
||||
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()
|
||||
if err := mockstore.CreateMessage(ctx, &testCon); err != nil {
|
||||
assert.NoError(t, err, "Error creating message")
|
||||
|
||||
@@ -24,15 +24,15 @@ func TestUpdateScheduledMessageStatusWithMock(t *testing.T) {
|
||||
messageStore := mock.NewMockMessageStore()
|
||||
schMsgStore := mock.NewMockScheduledMessageStore()
|
||||
|
||||
recipientId := uuid.New()
|
||||
contactId := uuid.New()
|
||||
messageId := uuid.New()
|
||||
scheduledMessageId := uuid.New()
|
||||
testUserId := uuid.New()
|
||||
|
||||
con := TestContact(recipientId, testUserId)
|
||||
msg := TestMessage(messageId, testUserId)
|
||||
schMsg := TestScheduledMessage(scheduledMessageId, testUserId, now)
|
||||
event := TestScheduledMessageEvent(msg.Id, *con.Id, schMsg.Id)
|
||||
con := ContactTest(contactId, testUserId)
|
||||
msg := MessageTest(messageId, testUserId)
|
||||
schMsg := ScheduledMessageTest(scheduledMessageId, testUserId, now)
|
||||
event := ScheduledMessageEventTest(*msg.Id, *con.Id, schMsg.Id)
|
||||
|
||||
ctx := t.Context()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user