tsk-51: Send message endpoint (#52)

Closes #51

Reviewed-on: phoenix/textsender-api#52
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
phoenix
2025-12-10 21:35:02 +00:00
committed by phoenix
parent 20ffc45f89
commit 0d252bc261
32 changed files with 753 additions and 96 deletions
+9 -4
View File
@@ -25,7 +25,10 @@ type Request struct {
func TestCreateContactWithMock(t *testing.T) {
mockstore := mock.NewMockContactStore()
handler := NewContactHandler(mockstore)
apiApp, err := GetApp()
assert.NoError(t, err, "Error getting app")
handler := NewContactHandler(apiApp, mockstore)
testUserId := uuid.New()
testBody := Request{PhoneNumber: "+12335403383", UserId: testUserId}
@@ -39,7 +42,7 @@ func TestCreateContactWithMock(t *testing.T) {
assert.Equal(t, http.StatusCreated, rr.Code)
var response AddContactResponse
err := json.Unmarshal(rr.Body.Bytes(), &response)
err = json.Unmarshal(rr.Body.Bytes(), &response)
assert.NoError(t, err, "Error Creating contact %v", err)
assert.NotEmpty(t, response.Data, "No Contact created")
@@ -62,13 +65,15 @@ func TestGetContactWithMock(t *testing.T) {
req, _ := http.NewRequest("GET", url, nil)
rr := httptest.NewRecorder()
contactHandler := NewContactHandler(mockstore)
apiApp, err := GetApp()
assert.NoError(t, err, "Error getting app")
contactHandler := NewContactHandler(apiApp, mockstore)
contactHandler.GetContact(rr, req)
assert.Equal(t, http.StatusOK, rr.Code)
var response GetContactResponse
err := json.Unmarshal(rr.Body.Bytes(), &response)
err = json.Unmarshal(rr.Body.Bytes(), &response)
assert.NoError(t, err, "Error getting contact %v", err)
assert.NotEmpty(t, response.Data, "No Contact retrieved")