-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from moeyashi/feature/57
Feature/57
- Loading branch information
Showing
9 changed files
with
114 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
# flyctl launch added from .gitignore | ||
node_modules | ||
**\.env | ||
.github/ | ||
node_modules/ | ||
wr-python/ | ||
**/.env* | ||
.eslint* | ||
.git* | ||
fly.toml | ||
**/*.md | ||
schema.hcl | ||
**/*.test.* |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Test | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
services: | ||
postgres: | ||
image: postgres | ||
# refer: https://hub.docker.com/_/postgres | ||
env: | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_USER: postgres | ||
POSTGRES_DB: postgres | ||
ports: | ||
- 25432:5432 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ariga/setup-atlas@master | ||
- uses: actions/setup-node@v4 | ||
with: | ||
cache: "npm" | ||
- run: npm install | ||
- run: npm test run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { execSync } from 'child_process'; | ||
import { expect, test, describe, beforeAll } from 'vitest'; | ||
import { postgresNitaRepository } from './nita.js'; | ||
|
||
describe('postgresNitaRepository', () => { | ||
const repo = postgresNitaRepository(); | ||
describe('selectRanking', async () => { | ||
const trackCode = 'MKS'; | ||
const users = Array.from({ length: 21 }).map((_, i) => ({ | ||
user: { id: `${i + 1}` }, | ||
})); | ||
beforeAll(async () => { | ||
execSync('npm run db:reset'); | ||
for (const i of users) { | ||
await repo.insertNita({ | ||
discordUserId: i.user.id, | ||
trackCode, | ||
milliseconds: i.user.id === '2' ? 99999 : 1000 + Number(i.user.id), | ||
}); | ||
} | ||
}); | ||
|
||
test('上位20名が取得されること', async () => { | ||
const ranking = await repo.selectRanking(trackCode, users); | ||
expect(ranking).toEqual([ | ||
{ member: { user: { id: '1' } }, milliseconds: 1001 }, | ||
{ member: { user: { id: '3' } }, milliseconds: 1003 }, | ||
{ member: { user: { id: '4' } }, milliseconds: 1004 }, | ||
{ member: { user: { id: '5' } }, milliseconds: 1005 }, | ||
{ member: { user: { id: '6' } }, milliseconds: 1006 }, | ||
{ member: { user: { id: '7' } }, milliseconds: 1007 }, | ||
{ member: { user: { id: '8' } }, milliseconds: 1008 }, | ||
{ member: { user: { id: '9' } }, milliseconds: 1009 }, | ||
{ member: { user: { id: '10' } }, milliseconds: 1010 }, | ||
{ member: { user: { id: '11' } }, milliseconds: 1011 }, | ||
{ member: { user: { id: '12' } }, milliseconds: 1012 }, | ||
{ member: { user: { id: '13' } }, milliseconds: 1013 }, | ||
{ member: { user: { id: '14' } }, milliseconds: 1014 }, | ||
{ member: { user: { id: '15' } }, milliseconds: 1015 }, | ||
{ member: { user: { id: '16' } }, milliseconds: 1016 }, | ||
{ member: { user: { id: '17' } }, milliseconds: 1017 }, | ||
{ member: { user: { id: '18' } }, milliseconds: 1018 }, | ||
{ member: { user: { id: '19' } }, milliseconds: 1019 }, | ||
{ member: { user: { id: '20' } }, milliseconds: 1020 }, | ||
{ member: { user: { id: '21' } }, milliseconds: 1021 }, | ||
]); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineConfig } from "vitest/config"; | ||
|
||
export default defineConfig({ | ||
test: { | ||
env: { | ||
DATABASE_HOST: "localhost", | ||
DATABASE_PORT: "25432", | ||
DATABASE_USERNAME: "postgres", | ||
DATABASE_PASSWORD: "postgres", | ||
}, | ||
}, | ||
}); |