-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* dto 수정 * .env * 폴더 수정 완료
- Loading branch information
Showing
24 changed files
with
156 additions
and
148 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 |
---|---|---|
@@ -1 +1,3 @@ | ||
MONGODB_URI=mongodb://localhost:27017/musicspot | ||
DB_HOST=localhost | ||
DB_PORT=27017 | ||
DB_NAME=musicspot |
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
10 changes: 5 additions & 5 deletions
10
...sicspot/src/journey/journey.controller.ts → .../journey/controller/journey.controller.ts
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,3 +1,4 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { | ||
ArrayMaxSize, | ||
ArrayMinSize, | ||
|
@@ -7,15 +8,30 @@ import { | |
} from 'class-validator'; | ||
|
||
export class StartJourneyDTO { | ||
@ApiProperty({ | ||
example: [37.555946, 126.972384], | ||
description: '위치 좌표', | ||
required: true, | ||
}) | ||
@IsArray() | ||
@ArrayMaxSize(2, { message: 'coordinate has only 2' }) | ||
@ArrayMinSize(2, { message: 'coordinate has only 2' }) | ||
@IsNumber({}, { each: true }) | ||
readonly coordinate: number[]; | ||
|
||
@ApiProperty({ | ||
example: '2023-11-22T12:00:00Z', | ||
description: 'timestamp', | ||
required: true, | ||
}) | ||
@IsString() | ||
readonly timestamp: string; | ||
|
||
@ApiProperty({ | ||
example: '[email protected]', | ||
description: '이메일', | ||
required: true, | ||
}) | ||
@IsString() | ||
readonly email: string; | ||
} |
This file was deleted.
Oops, something went wrong.
12 changes: 6 additions & 6 deletions
12
BE/musicspot/src/journey/journey.module.ts → ...spot/src/journey/module/journey.module.ts
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
File renamed without changes.
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,68 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { JourneyService } from './journey.service'; | ||
import mongoose from 'mongoose'; | ||
import { User, UserSchema } from '../../user/schema/user.schema'; | ||
import { Journey, JourneySchema } from '../schema/journey.schema'; | ||
import { getModelToken } from '@nestjs/mongoose'; | ||
import { StartJourneyDTO } from '../dto/journeyStart.dto'; | ||
import { UserService } from '../../user/serivce/user.service'; | ||
|
||
describe('JourneysService', () => { | ||
let service: JourneyService; | ||
let userModel; | ||
let journeyModel; | ||
|
||
beforeAll(async () => { | ||
mongoose.connect( | ||
`mongodb://${process.env.DB_HOST}:${process.env.DB_PORT}/${process.env.DB_NAME}`, | ||
); | ||
userModel = mongoose.model(User.name, UserSchema); | ||
journeyModel = mongoose.model(Journey.name, JourneySchema); | ||
|
||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [ | ||
JourneyService, | ||
UserService, | ||
{ | ||
provide: getModelToken(Journey.name), | ||
useValue: journeyModel, | ||
}, | ||
{ | ||
provide: getModelToken(User.name), | ||
useValue: userModel, | ||
}, | ||
], | ||
}).compile(); | ||
|
||
service = module.get<JourneyService>(JourneyService); | ||
}); | ||
|
||
it('journey 시작 테스트', async () => { | ||
const coordinate = [37.675986, 126.776032]; | ||
const timestamp = '2023-11-22T15:30:00.000+09:00'; | ||
const email = 'test-email'; | ||
|
||
const createJourneyData: StartJourneyDTO = { | ||
coordinate, | ||
timestamp, | ||
email, | ||
}; | ||
|
||
const createdJourneyData = | ||
await service.insertJourneyData(createJourneyData); | ||
expect(coordinate).toEqual(createdJourneyData.coordinates[0]); | ||
expect(timestamp).toEqual(createdJourneyData.timestamp); | ||
expect(createdJourneyData.spots).toEqual([]); | ||
|
||
const updateUserInfo = await service.pushJourneyIdToUser( | ||
createdJourneyData._id, | ||
email, | ||
); | ||
// console.log(createdUserData); | ||
expect(updateUserInfo.modifiedCount).toEqual(1); | ||
}); | ||
|
||
afterAll(async () => { | ||
mongoose.connection.close(); | ||
}); | ||
}); |
12 changes: 6 additions & 6 deletions
12
BE/musicspot/src/journey/journey.service.ts → ...ot/src/journey/service/journey.service.ts
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
File renamed without changes.
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
Oops, something went wrong.