songs-iidx fixture

This commit is contained in:
zkldi
2021-04-24 15:32:28 +01:00
parent fe509c9470
commit 6bce7fc015
5 changed files with 32 additions and 11 deletions
+2
View File
@@ -6,3 +6,5 @@ src/secrets.ts
src/scripts/validate-database-errs/*
.nyc_output
coverage
.env
setenv.sh
+15 -2
View File
@@ -1,13 +1,25 @@
import t from "tap";
import mockApi from "../../test-utils/mock-api";
import { TestingIIDXEamusementCSV26, TestingIIDXEamusementCSV27 } from "../../test-utils/test-data";
import {
GetKTDataJSON,
TestingIIDXEamusementCSV26,
TestingIIDXEamusementCSV27,
} from "../../test-utils/test-data";
import { CloseAllConnections } from "../../test-utils/close-connections";
import { RequireNeutralAuthentication } from "../../test-utils/api-common";
import { CreateFakeAuthCookie } from "../../test-utils/fake-session";
import ResetDBState from "../../test-utils/reset-db-state";
import { rootLogger } from "../../logger";
import dump from "why-is-node-running";
import { GetUnsuccessfulScores } from "../../test-utils/score-import-utils";
import db from "../../db/db";
async function LoadKTBlackSongsIIDX() {
let data = GetKTDataJSON("./kamaitachi/ktblack-songs-iidx.json");
await db.songs.iidx.remove({});
await db.songs.iidx.insert(data);
}
// reset DB handles the post-stuff
t.test("POST /internal-api/import/file", async (t) => {
const cookie = await CreateFakeAuthCookie(mockApi);
@@ -17,6 +29,7 @@ t.test("POST /internal-api/import/file", async (t) => {
RequireNeutralAuthentication("/internal-api/import/file", "POST");
t.test("csv:eamusement-iidx", (t) => {
t.beforeEach(LoadKTBlackSongsIIDX);
t.test("Valid Rootage CSV import", async (t) => {
let res = await mockApi
.post("/internal-api/import/file")
+3
View File
@@ -11,6 +11,9 @@ function FormatVersion() {
return `v${[major, minor, patch].join(".")} (${name})`;
}
import dotenv from "dotenv";
dotenv.config();
import CreateLogCtx from "./logger";
import server from "./server";
import serverConfig from "./server-config";
+11 -9
View File
@@ -5,30 +5,32 @@ import { DryScore } from "../types";
const file = (name: string) => path.join(__dirname, "/test-data", name);
const JSONFile = (name: string) => JSON.parse(fs.readFileSync(file(name), "utf-8"));
const BufferFromFile = (name: string) => fs.readFileSync(file(name));
export const GetKTDataJSON = (name: string) => JSON.parse(fs.readFileSync(file(name), "utf-8"));
export const GetKTDataBuffer = (name: string) => fs.readFileSync(file(name));
export const TestingIIDXSPDryScore = JSONFile(
export const TestingIIDXSPDryScore = GetKTDataJSON(
"./kamaitachi/iidx-dryscore.json"
) as DryScore<"iidx:SP">;
export const Testing511SPA = JSONFile("./kamaitachi/iidx-511spa.json") as ChartDocument<"iidx:SP">;
export const Testing511SPA = GetKTDataJSON(
"./kamaitachi/iidx-511spa.json"
) as ChartDocument<"iidx:SP">;
export const TestingDoraChart = JSONFile(
export const TestingDoraChart = GetKTDataJSON(
"./kamaitachi/gitadora-ithinkabtyou.json"
) as ChartDocument<"gitadora:Dora">;
export const TestingSDVXSingleDryScore = JSONFile(
export const TestingSDVXSingleDryScore = GetKTDataJSON(
"./kamaitachi/sdvx-dryscore.json"
) as DryScore<"sdvx:Single">;
export const TestingGITADORADoraDryScore = JSONFile(
export const TestingGITADORADoraDryScore = GetKTDataJSON(
"./kamaitachi/gitadora-dryscore.json"
) as DryScore<"gitadora:Dora">;
export const TestingIIDXEamusementCSV26 = BufferFromFile(
export const TestingIIDXEamusementCSV26 = GetKTDataBuffer(
"./csv-eamusement-iidx/pre-leggendaria.csv"
);
export const TestingIIDXEamusementCSV27 = BufferFromFile(
export const TestingIIDXEamusementCSV27 = GetKTDataBuffer(
"./csv-eamusement-iidx/post-leggendaria.csv"
);
File diff suppressed because one or more lines are too long