diff --git a/internal/handler/helper_test.go b/internal/handler/helper_test.go index 4c4c656..0fd8221 100644 --- a/internal/handler/helper_test.go +++ b/internal/handler/helper_test.go @@ -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) diff --git a/internal/handler/message_event_response_test.go b/internal/handler/message_event_response_test.go index b6e48ba..388763e 100644 --- a/internal/handler/message_event_response_test.go +++ b/internal/handler/message_event_response_test.go @@ -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() diff --git a/internal/handler/message_test.go b/internal/handler/message_test.go index 0fbb03e..d162e78 100644 --- a/internal/handler/message_test.go +++ b/internal/handler/message_test.go @@ -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") diff --git a/internal/handler/schedule_message_status_test.go b/internal/handler/schedule_message_status_test.go index 0d8a2f4..d868620 100644 --- a/internal/handler/schedule_message_status_test.go +++ b/internal/handler/schedule_message_status_test.go @@ -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()