-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write events test suite #181
Changes from 26 commits
c12ac20
ef89fa3
bc43ff9
ce6dcb8
290c828
159d169
bbaedc2
6a9b5ae
74db6ba
d2fd439
8d7623d
a264273
caa4f92
a33bcd0
fcc0e4a
e56e157
cc6f83b
8ef3ea1
5b3fa0c
6e55d48
2f8c3b4
2529a86
28a55ca
ede38bf
539d35e
18a952c
342dcb5
a70a68e
cc1694b
9b51a89
3ecb774
2c5ca2a
a88706e
98023da
298f5f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ | |
"pg": "^8.6.0", | ||
"reflect-metadata": "^0.1.13", | ||
"routing-controllers": "^0.9.0", | ||
"ts-mockito": "^2.6.1", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: dev dependency. |
||
"ts-node": "^9.1.1", | ||
"tsconfig-paths": "^3.9.0", | ||
"typedi": "^0.8.0", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ export default class EventService { | |
public async create(event: Event) { | ||
const eventCreated = await this.transactions.readWrite(async (txn) => { | ||
const eventRepository = Repositories.event(txn); | ||
const isUnusedAttendanceCode = eventRepository.isUnusedAttendanceCode(event.attendanceCode); | ||
const isUnusedAttendanceCode = await eventRepository.isUnusedAttendanceCode(event.attendanceCode); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you catch this with a test or just notice it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was caught with test - I saw that the duplicate attendance code error was thrown by Postgres' duplicate key constraint and not by the event service There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, our first bug caught by testing! |
||
if (!isUnusedAttendanceCode) throw new UserError('Attendance code has already been used'); | ||
return eventRepository.upsertEvent(EventModel.create(event)); | ||
}); | ||
|
@@ -61,7 +61,7 @@ export default class EventService { | |
const currentEvent = await eventRepository.findByUuid(uuid); | ||
if (!currentEvent) throw new NotFoundError('Event not found'); | ||
if (changes.attendanceCode !== currentEvent.attendanceCode) { | ||
const isUnusedAttendanceCode = eventRepository.isUnusedAttendanceCode(changes.attendanceCode); | ||
const isUnusedAttendanceCode = await eventRepository.isUnusedAttendanceCode(changes.attendanceCode); | ||
if (!isUnusedAttendanceCode) throw new UserError('Attendance code has already been used'); | ||
Comment on lines
63
to
65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
return eventRepository.upsertEvent(currentEvent, changes); | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this change for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved SubmitEventFeedbackRequest from FeedbackControllerRequests to EventControllerRequests