Skip to content

Commit

Permalink
exercise: add exercise #3
Browse files Browse the repository at this point in the history
  • Loading branch information
haroldcohen committed Nov 24, 2023
1 parent 11dad4b commit dbc7fe7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
24 changes: 2 additions & 22 deletions src/driven/repositories/typeorm/carRental/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,11 @@ export default class TypeORMCarRentalReadRepository implements CarRentalReadRepo
}

private async queryBuilder(): Promise<SelectQueryBuilder<TypeORMCarRental>> {
const queryRunner = this.dataSource.createQueryRunner("slave");
return this.dataSource
.createQueryBuilder(TypeORMCarRental, "car", queryRunner)
.setQueryRunner(queryRunner);
// EXERCISE #3: MISSING CODE HERE
}

async read(id: string): Promise<CarRental> {

Check failure on line 22 in src/driven/repositories/typeorm/carRental/read.ts

View workflow job for this annotation

GitHub Actions / lint (20.x)

'id' is defined but never used
const queryBuilder = await this.queryBuilder();

Check failure on line 23 in src/driven/repositories/typeorm/carRental/read.ts

View workflow job for this annotation

GitHub Actions / lint (20.x)

'queryBuilder' is assigned a value but never used
const retrievedCarRental = await queryBuilder
.setFindOptions({where: {id}, relations: ['customer', 'car', 'car.model']})
.getOne() as TypeORMCarRental;

return new CarRental({
id,
customerId: retrievedCarRental.customer.id,
totalPrice: retrievedCarRental.totalPrice,
pickupDateTime: retrievedCarRental.pickupDateTime,
dropOffDateTime: retrievedCarRental.dropOffDateTime,
car: new Car({
id: retrievedCarRental.car.id,
model: new CarModel({
id: retrievedCarRental.car.model.id,
dailyRate: retrievedCarRental.car.model.dailyRate,
})
})
})
// EXERCISE #3: MISSING CODE HERE
}
}
2 changes: 1 addition & 1 deletion tests/integration/typeorm/carRental/query/read.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe.each([
})

afterEach(async () => {
await runDataSourceAfterEachOps();
// EXERCISE #3: MISSING CODE HERE
})

test(`Read a car rental ${testCase.rental.id} should return one car rental`, async () => {
Expand Down

0 comments on commit dbc7fe7

Please sign in to comment.