-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from igh9410/dev
Chat Room client one-to-one almost done
- Loading branch information
Showing
25 changed files
with
434 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package chat | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/DATA-DOG/go-sqlmock" | ||
"github.com/google/uuid" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCreateChatRoom(t *testing.T) { | ||
db, mock, err := sqlmock.New() | ||
if err != nil { | ||
t.Fatalf("An error '%s' was not expected when opening a stub database connection", err) | ||
} | ||
defer db.Close() | ||
|
||
repo := NewRepository(db) | ||
|
||
chatRoom := &ChatRoom{} | ||
expectedID := uuid.New() | ||
|
||
// Set up the expectations | ||
mock.ExpectQuery("INSERT INTO chat_rooms"). | ||
WithArgs(sqlmock.AnyArg(), sqlmock.AnyArg()). | ||
WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(expectedID)) | ||
|
||
// Call the method under test | ||
result, err := repo.CreateChatRoom(context.Background(), chatRoom) | ||
|
||
// Assert the expectations | ||
assert.NoError(t, err) | ||
assert.Equal(t, expectedID, result.ID) | ||
|
||
// Ensure all expectations were met | ||
if err := mock.ExpectationsWereMet(); err != nil { | ||
t.Errorf("there were unfulfilled expectations: %s", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
EXPLAIN ANALYZE SELECT id, chat_room_id, sender_id, content, media_url, created_at, read_at, deleted_by_user_id | ||
FROM messages | ||
WHERE chat_room_id = '21e546be-629d-4e84-9236-b05c69becb18' | ||
ORDER BY created_at DESC | ||
LIMIT 50 OFFSET 0; | ||
|
||
EXPLAIN ANALYZE SELECT id, chat_room_id, sender_id, content, media_url, created_at, read_at, deleted_by_user_id | ||
FROM messages | ||
WHERE chat_room_id = '21e546be-629d-4e84-9236-b05c69becb18' | ||
AND id < 12000 | ||
ORDER BY id DESC | ||
LIMIT 50; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.layout { | ||
display: flex; | ||
flex-direction: column; | ||
height: 100vh; /* This ensures the container takes the full height of the viewport */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import styles from './Layout.module.scss'; | ||
import { Header } from '@components/Header'; | ||
|
||
type LayoutProps = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
export const Layout = ({ children }: LayoutProps) => { | ||
return ( | ||
<div className={styles.layout}> | ||
<Header /> | ||
{children} | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.