Skip to content

Commit 7c4327a

Browse files
fix: use development main branch of knexjs
1 parent 79d8535 commit 7c4327a

3 files changed

Lines changed: 133 additions & 97 deletions

File tree

apps/backend/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
},
1212
"dependencies": {
1313
"@hono/node-server": "^1.19.7",
14-
"@hono/standard-validator": "^0.2.0",
15-
"@hono/zod-validator": "^0.7.5",
14+
"@hono/standard-validator": "^0.2.1",
15+
"@hono/zod-validator": "^0.7.6",
1616
"@logtape/hono": "^1.3.5",
1717
"@logtape/logtape": "^1.3.5",
1818
"better-sqlite3": "^12.5.0",
19-
"hono": "^4.10.8",
19+
"hono": "^4.11.3",
2020
"hono-openapi": "^1.1.2",
21-
"knex": "^3.1.0",
22-
"zod": "^4.1.13"
21+
"knex": "github:knex/knex#master",
22+
"zod": "^4.3.5"
2323
},
2424
"devDependencies": {
25-
"@faker-js/faker": "^10.1.0"
25+
"@faker-js/faker": "^10.2.0"
2626
}
2727
}

apps/backend/src/v1/season/service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { knexDb } from "@db/knexfile";
12
import type { SeasonRecord } from "@v1/season/models";
23
import type { Knex } from "knex";
34
import type { SeasonQuery } from "./schemas";
@@ -9,7 +10,7 @@ import type { SeasonQuery } from "./schemas";
910
*/
1011
export async function getSeasons(
1112
season_query: SeasonQuery,
12-
db: Knex,
13+
db: Knex = knexDb,
1314
): Promise<Array<SeasonRecord>> {
1415
const { season_id, guild_id, season_name, after, before } = season_query;
1516
const query = db<SeasonRecord>("Season").select();
@@ -20,7 +21,7 @@ export async function getSeasons(
2021
query.where({ season_id });
2122
}
2223
if (season_name) {
23-
query.whereILike(season_name, `%{season_name}%`);
24+
query.whereILike("season_name", `%${season_name}%`);
2425
}
2526
if (after) {
2627
query.where("end_at", ">=", after);

apps/backend/src/v1/season/test/integration.test.ts

Lines changed: 124 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -42,100 +42,135 @@ afterEach(async () => {
4242
});
4343

4444
describe("Season table operations", () => {
45-
let past_season: Omit<SeasonRecord, "season_id">;
46-
let current_season: Omit<SeasonRecord, "season_id">;
47-
let future_season: Omit<SeasonRecord, "season_id">;
4845
describe("Use `getSeasons`", () => {
49-
beforeEach(async () => {
50-
past_season = pastSeasonRecordFactory();
51-
current_season = currentSeasonRecordFactory();
52-
future_season = futureSeasonRecordFactory();
53-
await seed_db(
54-
new TestSeedSource({
55-
season_records: [past_season, current_season, future_season],
56-
}),
57-
test_knexDb,
58-
);
59-
});
60-
test("Based on `after` and `before` arguments", async () => {
61-
const current_result = await getSeasons(
62-
{ before: new Date().toISOString(), after: new Date().toISOString() },
63-
test_knexDb,
64-
);
65-
expect(current_result, "Returns only the ongoing Season").toHaveLength(1);
66-
expect(current_result[0]).toMatchObject(current_season);
46+
describe("Based on `after` and `before` arguments", async () => {
47+
let past_season: Omit<SeasonRecord, "season_id">;
48+
let current_season: Omit<SeasonRecord, "season_id">;
49+
let future_season: Omit<SeasonRecord, "season_id">;
50+
beforeEach(async () => {
51+
past_season = pastSeasonRecordFactory();
52+
current_season = currentSeasonRecordFactory();
53+
future_season = futureSeasonRecordFactory();
54+
await seed_db(
55+
new TestSeedSource({
56+
season_records: [past_season, current_season, future_season],
57+
}),
58+
test_knexDb,
59+
);
60+
});
61+
test("Nominal", async () => {
62+
const current_result = await getSeasons(
63+
{
64+
before: new Date().toISOString(),
65+
after: new Date().toISOString(),
66+
},
67+
test_knexDb,
68+
);
69+
expect(current_result, "Returns only the ongoing Season").toHaveLength(
70+
1,
71+
);
72+
expect(current_result[0]).toMatchObject(current_season);
6773

68-
const reverse_result = await getSeasons(
69-
{
70-
before: new Date(Date.now() - 1000).toISOString(),
71-
after: new Date(Date.now() + 1000).toISOString(),
72-
},
73-
test_knexDb,
74-
);
75-
expect(reverse_result, "`after` > `before`").toHaveLength(1);
76-
expect(reverse_result[0]).toMatchObject(current_season);
74+
const reverse_result = await getSeasons(
75+
{
76+
before: new Date(Date.now() - 1000).toISOString(),
77+
after: new Date(Date.now() + 1000).toISOString(),
78+
},
79+
test_knexDb,
80+
);
81+
expect(reverse_result, "`after` > `before`").toHaveLength(1);
82+
expect(reverse_result[0]).toMatchObject(current_season);
7783

78-
const current_future_result = await getSeasons(
79-
{ after: new Date().toISOString() },
80-
test_knexDb,
81-
);
82-
expect(current_future_result, "Returns current and future").toHaveLength(2);
83-
expect(current_future_result).toEqual(
84-
expect.arrayContaining([
85-
expect.objectContaining(current_season),
86-
expect.objectContaining(future_season),
87-
]),
88-
);
84+
const current_future_result = await getSeasons(
85+
{ after: new Date().toISOString() },
86+
test_knexDb,
87+
);
88+
expect(
89+
current_future_result,
90+
"Returns current and future",
91+
).toHaveLength(2);
92+
expect(current_future_result).toEqual(
93+
expect.arrayContaining([
94+
expect.objectContaining(current_season),
95+
expect.objectContaining(future_season),
96+
]),
97+
);
8998

90-
const current_past_result = await getSeasons(
91-
{ before: new Date().toISOString() },
92-
test_knexDb,
93-
);
94-
expect(current_past_result, "Returns current and past").toHaveLength(2);
95-
expect(current_past_result).toEqual(
96-
expect.arrayContaining([
97-
expect.objectContaining(current_season),
98-
expect.objectContaining(past_season),
99-
]),
100-
);
99+
const current_past_result = await getSeasons(
100+
{ before: new Date().toISOString() },
101+
test_knexDb,
102+
);
103+
expect(current_past_result, "Returns current and past").toHaveLength(2);
104+
expect(current_past_result).toEqual(
105+
expect.arrayContaining([
106+
expect.objectContaining(current_season),
107+
expect.objectContaining(past_season),
108+
]),
109+
);
110+
});
111+
test("Boundary", async () => {
112+
const before_at_start_result = await getSeasons(
113+
{
114+
before: new Date(
115+
new Date(current_season.start_at).getTime(),
116+
).toISOString(),
117+
},
118+
test_knexDb,
119+
);
120+
expect(
121+
before_at_start_result,
122+
"Set `before` to a Season's `start_at`",
123+
).toHaveLength(2);
124+
expect(before_at_start_result).toEqual(
125+
expect.arrayContaining([
126+
expect.objectContaining(current_season),
127+
expect.objectContaining(past_season),
128+
]),
129+
);
130+
const after_on_end_result = await getSeasons(
131+
{
132+
after: new Date(
133+
new Date(current_season.end_at).getTime(),
134+
).toISOString(),
135+
},
136+
test_knexDb,
137+
);
138+
expect(
139+
after_on_end_result,
140+
"Set `before` to a Season's `start_at`",
141+
).toHaveLength(2);
142+
expect(after_on_end_result).toEqual(
143+
expect.arrayContaining([
144+
expect.objectContaining(current_season),
145+
expect.objectContaining(future_season),
146+
]),
147+
);
148+
});
101149
});
102-
test("Boundary", async () => {
103-
const before_at_start_result = await getSeasons(
104-
{
105-
before: new Date(
106-
new Date(current_season.start_at).getTime(),
107-
).toISOString(),
108-
},
109-
test_knexDb,
110-
);
111-
expect(
112-
before_at_start_result,
113-
"Set `before` to a Season's `start_at`",
114-
).toHaveLength(2);
115-
expect(before_at_start_result).toEqual(
116-
expect.arrayContaining([
117-
expect.objectContaining(current_season),
118-
expect.objectContaining(past_season),
119-
]),
120-
);
121-
const after_on_end_result = await getSeasons(
122-
{
123-
after: new Date(
124-
new Date(current_season.end_at).getTime(),
125-
).toISOString(),
126-
},
127-
test_knexDb,
128-
);
129-
expect(
130-
after_on_end_result,
131-
"Set `before` to a Season's `start_at`",
132-
).toHaveLength(2);
133-
expect(after_on_end_result).toEqual(
134-
expect.arrayContaining([
135-
expect.objectContaining(current_season),
136-
expect.objectContaining(future_season),
137-
]),
138-
);
150+
describe("Based on `season_name`", async () => {
151+
let named_season: Omit<SeasonRecord, "season_id">;
152+
beforeEach(async () => {
153+
named_season = currentSeasonRecordFactory({
154+
season_name: "Real's Arena #64",
155+
});
156+
await seed_db(
157+
new TestSeedSource({
158+
season_records: [named_season],
159+
}),
160+
test_knexDb,
161+
);
162+
});
163+
test("Nominal", async () => {
164+
expect(
165+
await getSeasons(
166+
{ season_name: named_season.season_name },
167+
test_knexDb,
168+
),
169+
"Full name match",
170+
).toEqual(
171+
expect.arrayContaining([expect.objectContaining(named_season)]),
172+
);
173+
});
139174
});
140175
});
141176
});

0 commit comments

Comments
 (0)