Skip to content

Commit 5f68b60

Browse files
authored
fix: Small tweak to table and endpoint in integration test-api (#122)
Update test-api with new primary key, and require id when requesting by bundle name.
1 parent eaf8836 commit 5f68b60

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

integration-tests/test-api/src/index.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ console.log("connected to sqlite");
77

88
console.log('creating "stats" table');
99
const query = sqlite.query(
10-
"CREATE TABLE `stats` (`id` text, `bundle_name` text UNIQUE, `json_stats` text);",
10+
`CREATE TABLE "stats" (
11+
"id" text,
12+
"bundle_name" text,
13+
"json_stats" text,
14+
PRIMARY KEY ("id", "bundle_name")
15+
);`,
1116
);
1217
query.run();
1318
console.log('created "stats" table');
@@ -55,7 +60,7 @@ app.all("/file-upload/:id/:status{[0-9]{3}}", async (c) => {
5560
const data: { bundleName: string } = await c.req.json();
5661
console.log("finished upload");
5762

58-
console.log("inserting stats");
63+
console.log("inserting stats for", data.bundleName);
5964
const bundleName = data!.bundleName;
6065
const insertStats = JSON.stringify(data);
6166
const query = sqlite.query(
@@ -88,14 +93,15 @@ app.all("/get-stats/:id", (c) => {
8893
return c.text("Not found", { status: 404 });
8994
});
9095

91-
app.all("/get-stats-by-bundle-name/:bundleName", (c) => {
96+
app.all("/get-stats-by-bundle-name/:id/:bundleName", (c) => {
97+
const id = c.req.param("id");
9298
const bundleName = c.req.param("bundleName");
9399
console.log("getting stats", bundleName);
94100

95101
const query = sqlite.query(
96-
"SELECT * FROM stats WHERE bundle_name = $bundleName",
102+
"SELECT * FROM stats WHERE bundle_name = $bundleName AND id = $id",
97103
);
98-
const result = query.get({ $bundleName: bundleName }) as {
104+
const result = query.get({ $bundleName: bundleName, $id: id }) as {
99105
id: string;
100106
json_stats: string;
101107
};

0 commit comments

Comments
 (0)