alternate data processing

This commit is contained in:
2023-04-20 10:05:29 +02:00
parent 9284cce0ed
commit b609d7646e
13 changed files with 264 additions and 514 deletions
+3 -23
View File
@@ -2,7 +2,6 @@ import { afterAll, beforeAll, describe, expect, test } from '@jest/globals'
import clientMain from '../src/clientMain'
import * as dotenv from 'dotenv'
import db from '../src/db/db'
import cache from '../src/cache/redis'
dotenv.config()
let listenServer
@@ -16,9 +15,9 @@ describe('client', () => {
const request = await fetch("http://127.0.0.1:3000/servers")
const data = await request.json()
const first = Object.entries(data)[0]
expect(first[1]).toHaveProperty('name')
expect(first[1]).toHaveProperty('id')
expect(first[1]).toHaveProperty('description')
expect(first[1]).toHaveProperty('max_distance')
expect(first[1]).toHaveProperty('total_distance')
expect(first[1]).toHaveProperty('kills')
})
test('player list', async () => {
@@ -39,15 +38,6 @@ describe('client', () => {
expect(first[1]).toHaveProperty('kills')
})
test('player list with weapon and server filter', async () => {
const request = await fetch("http://127.0.0.1:3000/players?weapons=sniper&server=1")
const data = await request.json()
const first = Object.entries(data)[0]
expect(first[1]).toHaveProperty('max_distance')
expect(first[1]).toHaveProperty('total_distance')
expect(first[1]).toHaveProperty('kills')
})
test('weapon list', async () => {
const request = await fetch("http://127.0.0.1:3000/weapons")
const data = await request.json()
@@ -65,21 +55,11 @@ describe('client', () => {
expect(first[1]).toHaveProperty('total_distance')
expect(first[1]).toHaveProperty('kills')
})
test('weapon list with player and server filter', async () => {
const request = await fetch("http://127.0.0.1:3000/weapons?players=1005930844007&server=1")
const data = await request.json()
const first = Object.entries(data)[0]
expect(first[1]).toHaveProperty('max_distance')
expect(first[1]).toHaveProperty('total_distance')
expect(first[1]).toHaveProperty('kills')
})
})
afterAll((done) => {
listenServer.close(async () => {
await db.destroy()
await cache.quit()
done()
})
})
+4 -6
View File
@@ -4,7 +4,6 @@ import serverMain from '../src/serverMain'
import listenKills from "../src/process/onKill"
import * as dotenv from 'dotenv'
import db from '../src/db/db'
import cache from '../src/cache/redis'
dotenv.config()
let listenClient
@@ -62,8 +61,8 @@ beforeAll(async () => {
listenClient = await clientMain;
listenServer = await serverMain;
pgClient = await listenKills()
const yea = waitFor(10000)
const response = await fetch(`http://127.0.0.1:3001/${process.env.SERVERAUTH_ID}/kill`, {
const yea = waitFor(1000)
const response = await fetch(`http://127.0.0.1:3001/kill`, {
method: "POST", // *GET, POST, PUT, DELETE, etc.
credentials: "same-origin", // include, *same-origin, omit
headers: {
@@ -103,8 +102,8 @@ describe('realtime', () => {
test('update player', async () => {
jest.setTimeout(15000)
const yea = waitFor(10000)
const response = await fetch(`http://127.0.0.1:3001/${process.env.SERVERAUTH_ID}/kill`, {
const yea = waitFor(1000)
const response = await fetch(`http://127.0.0.1:3001/kill`, {
method: "POST", // *GET, POST, PUT, DELETE, etc.
credentials: "same-origin", // include, *same-origin, omit
headers: {
@@ -138,7 +137,6 @@ afterAll((done) => {
listenServer.close(async () => {
await pgClient.end()
await db.destroy()
await cache.quit()
done()
})
})