-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
180db03
commit 2ed7416
Showing
27 changed files
with
2,382 additions
and
88 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
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 |
---|---|---|
|
@@ -17,6 +17,13 @@ jobs: | |
- 5432:5432 | ||
# needed because the postgres container does not provide a healthcheck | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
hasura: | ||
image: hasura/graphql-engine:v1.1.1 | ||
ports: | ||
- "127.0.0.1:5001:8080" | ||
env: | ||
HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres | ||
HASURA_GRAPHQL_ENABLE_CONSOLE: "false" | ||
|
||
strategy: | ||
matrix: | ||
|
@@ -39,6 +46,15 @@ jobs: | |
- run: npm ci | ||
- run: npm run lint | ||
- run: npm run build | ||
- run: npm run db:migrate | ||
env: | ||
CI: true | ||
PG_HOST: 127.0.0.1 | ||
PG_PORT: 5432 | ||
PG_USER: postgres | ||
PG_PW: postgres | ||
PG_DB: postgres | ||
- run: npm run hasura:metadata:apply | ||
- run: npm test | ||
env: | ||
CI: true | ||
|
@@ -47,3 +63,15 @@ jobs: | |
PG_USER: postgres | ||
PG_PW: postgres | ||
PG_DB: postgres | ||
- name: Test & publish code coverage | ||
uses: paambaati/[email protected] | ||
env: | ||
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}} | ||
CI: true | ||
PG_HOST: 127.0.0.1 | ||
PG_PORT: 5432 | ||
PG_USER: postgres | ||
PG_PW: postgres | ||
PG_DB: postgres | ||
with: | ||
coverageCommand: npm run test:coverage |
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,3 +1,4 @@ | ||
.env | ||
node_modules | ||
dist | ||
dist | ||
coverage |
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,92 @@ | ||
import dotenv = require('dotenv'); | ||
import * as faker from 'faker'; | ||
import { Connection, createConnection } from 'typeorm'; | ||
|
||
import { entities, Match, Team } from '../entities'; | ||
import { RoundWinReason } from '../types/RoundWinReason.enum'; | ||
import { Round } from './round.entity'; | ||
|
||
dotenv.config(); | ||
|
||
let connection: Connection; | ||
let match: Match; | ||
|
||
describe("Entities", () => { | ||
beforeAll(async () => { | ||
connection = await createConnection({ | ||
type: "postgres", | ||
host: process.env.PG_HOST, | ||
port: parseInt(process.env.PG_PORT, 10), | ||
username: process.env.PG_USER, | ||
password: process.env.PG_PW, | ||
database: process.env.PG_DB, | ||
entities: entities, | ||
synchronize: false | ||
//logging: true | ||
}); | ||
}); | ||
|
||
afterAll(() => { | ||
connection.close(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
match = new Match(); | ||
match.teams = []; | ||
match.teams.push(new Team()); | ||
|
||
match.date = faker.date.past(1); | ||
match.externalId = faker.random.uuid(); | ||
|
||
await match.save(); | ||
|
||
match = await Match.findOne({ | ||
where: { id: match.id }, | ||
relations: ["teams", "rounds", "players"] | ||
}); | ||
}); | ||
|
||
// Seems like a stupid test.. and it is | ||
// But this way 'loads' entities and typechecks some stuff which might otherwise go unnoticed | ||
it("Match has an array several things", async () => { | ||
console.log(match); | ||
|
||
expect(match.teams).toBeInstanceOf(Array); | ||
expect(match.rounds).toBeInstanceOf(Array); | ||
expect(match.players).toBeInstanceOf(Array); | ||
}); | ||
|
||
it("Round has arrays of a lot of stuff", async () => { | ||
const roundData = new Round(); | ||
roundData.startTick = 1; | ||
roundData.endTick = 1337; | ||
roundData.winReason = RoundWinReason.BombDefused; | ||
await roundData.save(); | ||
|
||
const round = await Round.findOne({ | ||
where: { id: roundData.id }, | ||
relations: [ | ||
"bombStatusChanges", | ||
"weaponStatuses", | ||
"utilityThrowns", | ||
"utilityActivateds", | ||
"playerJumps", | ||
"kills", | ||
"playerBlinds", | ||
"playerHurts" | ||
] | ||
}); | ||
|
||
console.log(round); | ||
|
||
expect(round.bombStatusChanges).toBeInstanceOf(Array); | ||
expect(round.kills).toBeInstanceOf(Array); | ||
|
||
expect(round.playerBlinds).toBeInstanceOf(Array); | ||
expect(round.playerHurts).toBeInstanceOf(Array); | ||
expect(round.playerJumps).toBeInstanceOf(Array); | ||
expect(round.utilityActivateds).toBeInstanceOf(Array); | ||
expect(round.utilityThrowns).toBeInstanceOf(Array); | ||
expect(round.weaponStatuses).toBeInstanceOf(Array); | ||
}); | ||
}); |
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,6 +1,59 @@ | ||
export { Ban } from './ban.entity' | ||
export { Match } from './match.entity' | ||
export { Notification } from './notification.entity' | ||
export { Player as player } from './player.entity' | ||
export { UserSettings } from './user-settings.entity' | ||
export { User } from './user.entity' | ||
import { Ban } from './ban.entity'; | ||
import { BombStatus } from './bombStatus.entity'; | ||
import { Kill } from './kill.entity'; | ||
import { Match } from './match.entity'; | ||
import { Notification } from './notification.entity'; | ||
import { Player } from './player.entity'; | ||
import { PlayerBlind } from './playerBlind.entity'; | ||
import { PlayerHurt } from './playerHurt.entity'; | ||
import { PlayerInfo } from './playerInfo.entity'; | ||
import { PlayerJump } from './playerJump.entity'; | ||
import { Position } from './position.entity'; | ||
import { Round } from './round.entity'; | ||
import { Team } from './team.entity'; | ||
import { UserSettings } from './user-settings.entity'; | ||
import { User } from './user.entity'; | ||
import { UtilityActivated } from './utilityActivated.entity'; | ||
import { UtilityThrown } from './utilityThrown.entity'; | ||
import { WeaponStatus } from './weaponStatus.entity'; | ||
|
||
export { BombStatus } from "./bombStatus.entity"; | ||
export { Kill } from "./kill.entity"; | ||
export { PlayerBlind } from "./playerBlind.entity"; | ||
export { PlayerHurt } from "./playerHurt.entity"; | ||
export { PlayerInfo } from "./playerInfo.entity"; | ||
export { PlayerJump } from "./playerJump.entity"; | ||
export { Position } from "./position.entity"; | ||
export { Round } from "./round.entity"; | ||
export { Team } from "./team.entity"; | ||
export { UtilityActivated } from "./utilityActivated.entity"; | ||
export { UtilityThrown } from "./utilityThrown.entity"; | ||
export { WeaponStatus } from "./weaponStatus.entity"; | ||
|
||
export { Ban } from "./ban.entity"; | ||
export { Match } from "./match.entity"; | ||
export { Notification } from "./notification.entity"; | ||
export { Player } from "./player.entity"; | ||
export { UserSettings } from "./user-settings.entity"; | ||
export { User } from "./user.entity"; | ||
|
||
export const entities = [ | ||
Ban, | ||
Match, | ||
Notification, | ||
Player, | ||
Round, | ||
Team, | ||
User, | ||
UserSettings, | ||
BombStatus, | ||
Kill, | ||
PlayerBlind, | ||
PlayerHurt, | ||
PlayerInfo, | ||
PlayerJump, | ||
Position, | ||
UtilityActivated, | ||
UtilityThrown, | ||
WeaponStatus | ||
]; |
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
Oops, something went wrong.