Compare commits

...

15 commits

Author SHA1 Message Date
cea6569580
Implement /update
All checks were successful
/ prettier (pull_request) Successful in 41s
/ tests (pull_request) Successful in 47s
/ boot (pull_request) Successful in 42s
/ node-check (pull_request) Successful in 10s
/ node-check (push) Successful in 3s
/ prettier (push) Successful in 26s
/ boot (push) Successful in 26s
/ tests (push) Successful in 35s
2024-05-25 08:20:55 +00:00
10f8c6fc36
Merge branches '403-to-422' and 'add-tests'
All checks were successful
/ node-check (push) Successful in 8s
/ boot (push) Successful in 34s
/ prettier (push) Successful in 27s
/ tests (push) Successful in 37s
2024-05-25 08:11:34 +00:00
a26d01aced
Don't pull in dev deps unless necessary
All checks were successful
/ node-check (pull_request) Successful in 8s
/ prettier (pull_request) Successful in 31s
/ boot (pull_request) Successful in 33s
/ tests (pull_request) Successful in 46s
2024-05-25 08:08:02 +00:00
37b758c41c
Consolidate tests
All checks were successful
/ node-check (pull_request) Successful in 10s
/ prettier (pull_request) Successful in 51s
/ boot (pull_request) Successful in 47s
/ tests (pull_request) Successful in 45s
2024-05-25 08:06:08 +00:00
2166cb4a9a
Merge branch 'main' into keys-namespace-id-not-null
All checks were successful
Run node --check on everything / node-check (pull_request) Successful in 9s
Make sure the server is actually able to start / boot-test (pull_request) Successful in 39s
Check project using prettier / prettier (pull_request) Successful in 41s
Run node --check on everything / node-check (push) Successful in 7s
Check project using prettier / prettier (push) Successful in 22s
Make sure the server is actually able to start / boot-test (push) Successful in 27s
2024-05-25 07:40:16 +00:00
20580e2f4b
Fix a major bug
All checks were successful
Run node --check on everything / node-check (pull_request) Successful in 8s
Make sure the server is actually able to start / prettier (pull_request) Successful in 55s
Check project using prettier / prettier (pull_request) Successful in 1m4s
2024-05-25 07:39:12 +00:00
2baefce4b1
Merge branch 'main' into add-tests
All checks were successful
Run node --check on everything / node-check (pull_request) Successful in 8s
Make sure the server is actually able to start / boot-test (pull_request) Successful in 32s
/ test (pull_request) Successful in 42s
Check project using prettier / prettier (pull_request) Successful in 51s
2024-05-25 07:32:54 +00:00
1cd1e51273
Actually load the db data
All checks were successful
Run node --check on everything / node-check (pull_request) Successful in 6s
Check project using prettier / prettier (pull_request) Successful in 34s
Make sure the server is actually able to start / prettier (pull_request) Successful in 47s
/ test (pull_request) Successful in 57s
2024-05-25 07:31:12 +00:00
62ba83cc9c
Ugh
All checks were successful
Run node --check on everything / node-check (pull_request) Successful in 7s
Make sure the server is actually able to start / prettier (pull_request) Successful in 25s
Check project using prettier / prettier (pull_request) Successful in 45s
/ test (pull_request) Successful in 1m17s
2024-05-25 06:51:58 +00:00
d67ab5c291
Use code.forgejo.org
Some checks failed
/ test (pull_request) Failing after 1s
Run node --check on everything / node-check (pull_request) Successful in 7s
Check project using prettier / prettier (pull_request) Successful in 27s
Make sure the server is actually able to start / prettier (pull_request) Successful in 37s
2024-05-25 06:50:51 +00:00
bcf213a741
edit workflow
Some checks failed
/ test (pull_request) Failing after 0s
Run node --check on everything / node-check (pull_request) Successful in 6s
Make sure the server is actually able to start / prettier (pull_request) Successful in 28s
Check project using prettier / prettier (pull_request) Successful in 30s
2024-05-25 06:49:31 +00:00
fe38f98b68
Add basic precursors to actual working tests
Some checks failed
/ test (pull_request) Failing after 2s
Run node --check on everything / node-check (pull_request) Successful in 9s
Make sure the server is actually able to start / prettier (pull_request) Successful in 40s
Check project using prettier / prettier (pull_request) Successful in 37s
2024-05-25 06:45:03 +00:00
df9b10c8fc
Use 500 instead of 422
All checks were successful
Run node --check on everything / node-check (pull_request) Successful in 7s
Make sure the server is actually able to start / boot-test (pull_request) Successful in 25s
Check project using prettier / prettier (pull_request) Successful in 25s
A 500 just seems more appropriate in this case IMO.
2024-05-25 05:24:02 +00:00
f94c38ad42
422 (Unprocessable Content) feels more accurate than 403 (Forbidden) here.
All checks were successful
Run node --check on everything / node-check (pull_request) Successful in 6s
Check project using prettier / prettier (pull_request) Successful in 20s
Make sure the server is actually able to start / boot-test (pull_request) Successful in 27s
2024-05-25 04:58:50 +00:00
fa3f8e2359
Start to add tests 2024-05-25 04:12:26 +00:00
9 changed files with 80 additions and 55 deletions

View file

@ -1,18 +0,0 @@
name: "Make sure the server is actually able to start"
author: "9pfs@amcforum.wiki (h @ nest)"
on:
push:
branches:
- "main"
- "fp-edits"
pull_request:
types: [opened, synchronize, reopened]
jobs:
boot-test:
runs-on: docker
steps:
- uses: actions/checkout@v3
- id: dependencies
run: NODE_ENV=development npm ci
- id: boot-test
run: TEST_MODE=boot LISTEN_PATH=/tmp/webserver.sock node index.js

View file

@ -1,16 +0,0 @@
name: "Run node --check on everything"
author: "9pfs@amcforum.wiki (h @ nest)"
on:
push:
branches:
- "main"
- "fp-edits"
pull_request:
types: [opened, synchronize, reopened]
jobs:
node-check:
runs-on: docker
steps:
- uses: actions/checkout@v3
- id: check
run: for a in `find|grep -v node_modules|grep '\.js$'`; do node --check $a && echo "$a OK"; done

View file

@ -1,18 +0,0 @@
name: "Check project using prettier"
author: "9pfs@amcforum.wiki (h @ nest)"
on:
push:
branches:
- "main"
- "fp-edits"
pull_request:
types: [opened, synchronize, reopened]
jobs:
prettier:
runs-on: docker
steps:
- uses: actions/checkout@v3
- id: dependencies
run: NODE_ENV=development npm ci
- id: prettier
run: npx prettier --check .

View file

@ -0,0 +1,46 @@
on:
push:
branches:
- "main"
- "fp-edits"
pull_request:
types: [opened, synchronize, reopened]
jobs:
tests:
runs-on: docker
container: node:20-bookworm
services:
test-db:
image: postgres:16
env:
POSTGRES_DB: test-db
POSTGRES_PASSWORD: postgres
steps:
- uses: actions/checkout@v3
- run: apt-get update
- run: apt-get install -y postgresql-client
- run: NODE_ENV=production npm ci
- run: cat migrations/*.sql|PGPASSWORD=postgres psql -h test-db -U postgres test-db
- run: node tests/index.js
prettier:
runs-on: docker
steps:
- uses: actions/checkout@v3
- id: dependencies
run: NODE_ENV=development npm ci
- id: prettier
run: npx prettier --check .
node-check:
runs-on: docker
steps:
- uses: actions/checkout@v3
- id: check
run: for a in `find|grep -v node_modules|grep '\.js$'`; do node --check $a && echo "$a OK"; done
boot:
runs-on: docker
steps:
- uses: actions/checkout@v3
- id: dependencies
run: NODE_ENV=production npm ci
- id: boot-test
run: TEST_MODE=boot LISTEN_PATH=/tmp/webserver.sock node index.js

View file

@ -108,13 +108,35 @@ app.get("/hit/:ns/:key", async function (req, res) {
true,
);
return res
.status(counter_res == null ? 403 : 200)
.status(counter_res == null ? 500 : 200)
.json({ value: counter_res });
});
app.get("/hit/:key", async function (req, res) {
var counter_res = await counter_increment("default", req.params.key, 1, true);
return res
.status(counter_res == null ? 403 : 200)
.status(counter_res == null ? 500 : 200)
.json({ value: counter_res });
});
app.get("/update/:ns/:key", async function (req, res) {
var counter_res = await counter_increment(
req.params.ns,
req.params.key,
req.query.amount,
false,
);
return res
.status(counter_res == null ? 500 : 200)
.json({ value: counter_res });
});
app.get("/update/:key", async function (req, res) {
var counter_res = await counter_increment(
"default",
req.params.key,
req.query.amount,
false,
);
return res
.status(counter_res == null ? 500 : 200)
.json({ value: counter_res });
});
app.get("/get/:ns/:key", async function (req, res) {

View file

@ -1,7 +1,7 @@
-- Make sure that keys.namespace_id isn't able to be null
BEGIN;
-- Remove all null keys.namespace_id values. Nuking data like this is reckless, but it's the only option.
DROP FROM keys WHERE namespace_id = NULL;
DELETE FROM keys WHERE namespace_id = NULL;
-- Delete before adding to avoid conflicts
ALTER TABLE keys ALTER COLUMN namespace_id DROP NOT NULL;
ALTER TABLE keys ALTER COLUMN namespace_id SET NOT NULL;

1
tests/db-sanity.js Normal file
View file

@ -0,0 +1 @@
import "./test-db.js";

4
tests/index.js Normal file
View file

@ -0,0 +1,4 @@
// Each test should be imported here.
import "./db-sanity.js";
// This should be the last line.
console.log("Tests successful.");

4
tests/test-db.js Normal file
View file

@ -0,0 +1,4 @@
/* only intended to be used in the forgejo actions test environment */
import postgres from "postgres";
const sql = postgres("postgres://postgres:postgres@test-db/test-db");
export default sql;