-
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: [BE] 서버 리펙토링 및 시그널링 서버 에러 제거 #121
[BE]: 서버 리펙토링 및 시그널링 서버 에러 제거
- Loading branch information
Showing
18 changed files
with
311 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,5 @@ export const EVENT = { | |
REGISTER: 'register', | ||
SIGNALING: 'signaling', | ||
}; | ||
|
||
export const USE_FULL = 100; |
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,76 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { ChatGateway } from './chat.gateway'; | ||
import { ChatService } from './chat.service'; | ||
import Redis from 'ioredis'; | ||
import { RedisModule, getRedisToken } from '@liaoliaots/nestjs-redis'; | ||
import { MessageDto } from './dto/message.dto'; | ||
import { Socket } from 'socket.io'; | ||
import { WsException } from '@nestjs/websockets'; | ||
|
||
describe('ChatGateway', () => { | ||
let gateway: ChatGateway; | ||
let chatService: ChatService; | ||
let redisClient: Redis; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
imports: [ | ||
RedisModule.forRoot({ | ||
config: { | ||
host: 'localhost', | ||
port: 6379, | ||
}, | ||
}), | ||
], | ||
providers: [ChatGateway, ChatService], | ||
}).compile(); | ||
|
||
gateway = module.get<ChatGateway>(ChatGateway); | ||
chatService = module.get<ChatService>(ChatService); | ||
redisClient = module.get<Redis>(getRedisToken('default')); | ||
}); | ||
|
||
afterEach(async () => { | ||
await redisClient.flushall(); | ||
}); | ||
|
||
describe('Redis', () => { | ||
it('레디스와 연결에 성공한다.', async () => { | ||
expect(redisClient).toBeDefined(); | ||
const response = await redisClient.ping(); | ||
expect(response).toBe('PONG'); | ||
}); | ||
}); | ||
|
||
describe('sendMessage', () => { | ||
it('메시지를 보냈을때 room 정보가 없으면 예외가 발생한다.', async () => { | ||
//GIVEN | ||
const testMessageDto: MessageDto = { | ||
room: '', | ||
message: 'testMessage', | ||
}; | ||
const testSocket = { id: '12345' } as unknown as Socket; | ||
|
||
// WHEN | ||
const messageHandling = gateway.handleMessage(testMessageDto, testSocket); | ||
|
||
// THEN | ||
await expect(messageHandling).rejects.toThrow(WsException); | ||
}); | ||
|
||
it('메시지를 보냈을때 message 정보가 없으면 예외가 발생한다.', async () => { | ||
//GIVEN | ||
const testMessageDto: MessageDto = { | ||
room: 'testRoom', | ||
message: '', | ||
}; | ||
const testSocket = { id: '12345' } as unknown as Socket; | ||
|
||
// WHEN | ||
const messageHandling = gateway.handleMessage(testMessageDto, testSocket); | ||
|
||
// THEN | ||
await expect(messageHandling).rejects.toThrow(WsException); | ||
}); | ||
}); | ||
}); |
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,6 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { ChatGateway } from './chat.gateway'; | ||
import { ChatService } from './chat.service'; | ||
|
||
@Module({ providers: [ChatGateway, ChatService] }) | ||
export class ChatModule {} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export class MessageDto { | ||
room: string; | ||
message: string; | ||
nickname: string; | ||
} |
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 |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { EventsService } from './events.service'; | ||
import { WebRtcGateway } from 'src/webRTC/web-rtc.gateway'; | ||
|
||
@Module({ | ||
providers: [EventsService, WebRtcGateway], | ||
providers: [EventsService], | ||
exports: [EventsService], | ||
}) | ||
export class EventsModule {} |
File renamed without changes.
Oops, something went wrong.