From 02030adc2fe5438f2e83e8a5b83dc94fdbbf6d8d Mon Sep 17 00:00:00 2001 From: zkldi Date: Thu, 13 May 2021 07:50:12 +0100 Subject: [PATCH] sure --- .../framework/common/import-logger.test.ts | 4 +- .../common/batch-manual/converter.test.ts | 4 +- .../common/batch-manual/parser.test.ts | 48 +++++++++---------- .../eamusement-iidx-csv/converter.test.ts | 4 +- server/src/test-utils/mock-db/sessions.json | 2 +- 5 files changed, 29 insertions(+), 33 deletions(-) diff --git a/server/src/score-import/framework/common/import-logger.test.ts b/server/src/score-import/framework/common/import-logger.test.ts index 3c5eb6a5f..b980aba7d 100644 --- a/server/src/score-import/framework/common/import-logger.test.ts +++ b/server/src/score-import/framework/common/import-logger.test.ts @@ -5,14 +5,14 @@ import { PublicUserDocument } from "kamaitachi-common"; t.test("#CreateImportLoggerAndID", (t) => { let { importID, logger } = CreateImportLoggerAndID( { username: "foo", id: 1 } as PublicUserDocument, - "file/csv:eamusement-iidx" + "file/eamusement-iidx-csv" ); t.match(importID, /^[a-f0-9]{40}$/u, "Should return a 40 character importID."); // not possible to automate this, probably. logger.info( - "Namespaced log test - if this does not have 'file/csv:eamusement-iidx | foo (#1)' next to it, it's broke." + "Namespaced log test - if this does not have 'file/eamusement-iidx-csv | foo (#1)' next to it, it's broke." ); t.end(); diff --git a/server/src/score-import/import-types/common/batch-manual/converter.test.ts b/server/src/score-import/import-types/common/batch-manual/converter.test.ts index c8b640893..73b0ed1df 100644 --- a/server/src/score-import/import-types/common/batch-manual/converter.test.ts +++ b/server/src/score-import/import-types/common/batch-manual/converter.test.ts @@ -26,7 +26,7 @@ const context = { }; const ktdWrap = (msg: string, game: Game = "iidx", version = null): any => ({ - importType: "file/json:batch-manual", + importType: "file/batch-manual", message: new RegExp(escapeStringRegexp(msg), "u"), converterContext: { game, service: "foo", version }, data: {}, // any under t.match rules. @@ -327,7 +327,7 @@ t.test("#ConverterFn", (t) => { game: "iidx", service: "foo", comment: null, - importType: "file/json:batch-manual", + importType: "file/batch-manual", timeAchieved: null, scoreData: { lamp: "HARD CLEAR", diff --git a/server/src/score-import/import-types/common/batch-manual/parser.test.ts b/server/src/score-import/import-types/common/batch-manual/parser.test.ts index 0a70b25cb..9d4668691 100644 --- a/server/src/score-import/import-types/common/batch-manual/parser.test.ts +++ b/server/src/score-import/import-types/common/batch-manual/parser.test.ts @@ -47,7 +47,7 @@ function dm(sc: any) { t.test("#ParserFn", (t) => { t.test("Non-Object", (t) => { t.throws( - () => ParserFn(false, "file/json:batch-manual", logger), + () => ParserFn(false, "file/batch-manual", logger), new ScoreImportFatalError( 400, "Invalid BATCH-MANUAL (Not an object, recieved boolean.)" @@ -60,7 +60,7 @@ t.test("#ParserFn", (t) => { t.test("No Header", (t) => { t.throws( - () => ParserFn({ body: [] }, "file/json:batch-manual", logger), + () => ParserFn({ body: [] }, "file/batch-manual", logger), new ScoreImportFatalError( 400, "Could not retrieve head.game - is this valid BATCH-MANUAL?" @@ -73,8 +73,7 @@ t.test("#ParserFn", (t) => { t.test("No Game", (t) => { t.throws( - () => - ParserFn({ body: [], head: { service: "foo" } }, "file/json:batch-manual", logger), + () => ParserFn({ body: [], head: { service: "foo" } }, "file/batch-manual", logger), new ScoreImportFatalError( 400, "Could not retrieve head.game - is this valid BATCH-MANUAL?" @@ -90,7 +89,7 @@ t.test("#ParserFn", (t) => { () => ParserFn( { body: [], head: { service: "foo", game: "invalid_game" } }, - "file/json:batch-manual", + "file/batch-manual", logger ), new ScoreImportFatalError( @@ -104,7 +103,7 @@ t.test("#ParserFn", (t) => { () => ParserFn( { body: [], head: { service: "foo", game: 123 } }, - "file/json:batch-manual", + "file/batch-manual", logger ), new ScoreImportFatalError( @@ -122,7 +121,7 @@ t.test("#ParserFn", (t) => { () => ParserFn( { body: [], head: { service: "1", game: "iidx" } }, - "file/json:batch-manual", + "file/batch-manual", logger ), new ScoreImportFatalError( @@ -136,7 +135,7 @@ t.test("#ParserFn", (t) => { () => ParserFn( { body: [], head: { service: 1, game: "iidx" } }, - "file/json:batch-manual", + "file/batch-manual", logger ), new ScoreImportFatalError( @@ -152,7 +151,7 @@ t.test("#ParserFn", (t) => { t.test("Valid Empty BATCH-MANUAL", (t) => { let res = ParserFn( { body: [], head: { service: "foo", game: "iidx" } }, - "file/json:batch-manual", + "file/batch-manual", logger ); @@ -206,7 +205,7 @@ t.test("#ParserFn", (t) => { ], head: { service: "foo", game: "iidx" }, } as BatchManual), - "file/json:batch-manual", + "file/batch-manual", logger ); @@ -256,7 +255,7 @@ t.test("#ParserFn", (t) => { t.test("Valid HitMeta", (t) => { let res = ParserFn( dm({ hitMeta: { bp: 10, gauge: 100, gaugeHistory: null, comboBreak: 7 } }), - "file/json:batch-manual", + "file/batch-manual", logger ); @@ -292,7 +291,7 @@ t.test("#ParserFn", (t) => { t.test("Valid HitData", (t) => { let res = ParserFn( dm({ hitData: { pgreat: 1, great: null, bad: 0 } }), - "file/json:batch-manual", + "file/batch-manual", logger ); @@ -344,7 +343,7 @@ t.test("#ParserFn", (t) => { ], head: { service: "foo", game: "iidx" }, }), - "file/json:batch-manual", + "file/batch-manual", logger ); @@ -360,7 +359,7 @@ t.test("#ParserFn", (t) => { }); t.test("Non-numeric score", (t) => { - let fn = () => ParserFn(dm({ score: "123" }), "file/json:batch-manual", logger); + let fn = () => ParserFn(dm({ score: "123" }), "file/batch-manual", logger); t.throws( fn, @@ -374,8 +373,7 @@ t.test("#ParserFn", (t) => { }); t.test("Invalid timeAchieved", (t) => { - let fn = () => - ParserFn(dm({ timeAchieved: "string" }), "file/json:batch-manual", logger); + let fn = () => ParserFn(dm({ timeAchieved: "string" }), "file/batch-manual", logger); t.throws( fn, @@ -388,7 +386,7 @@ t.test("#ParserFn", (t) => { let fn2 = () => ParserFn( dm({ timeAchieved: 1_620_768_609_637 / 1000 }), - "file/json:batch-manual", + "file/batch-manual", logger ); @@ -406,7 +404,7 @@ t.test("#ParserFn", (t) => { t.test("Invalid Playtype", (t) => { // this is not a valid playtype for IIDX - let fn = () => ParserFn(dm({ playtype: "Single" }), "file/json:batch-manual", logger); + let fn = () => ParserFn(dm({ playtype: "Single" }), "file/batch-manual", logger); t.throws( fn, @@ -421,7 +419,7 @@ t.test("#ParserFn", (t) => { t.test("Invalid Identifier", (t) => { // this is not a valid playtype for IIDX - let fn = () => ParserFn(dm({ identifier: null }), "file/json:batch-manual", logger); + let fn = () => ParserFn(dm({ identifier: null }), "file/batch-manual", logger); t.throws(fn, mockErr("body[0].identifier | Expected string", "Received null [null]")); @@ -430,7 +428,7 @@ t.test("#ParserFn", (t) => { t.test("Invalid MatchType", (t) => { let fn = () => - ParserFn(dm({ matchType: "Invalid_MatchType" }), "file/json:batch-manual", logger); + ParserFn(dm({ matchType: "Invalid_MatchType" }), "file/batch-manual", logger); t.throws( fn, @@ -444,13 +442,12 @@ t.test("#ParserFn", (t) => { }); t.test("Invalid HitData", (t) => { - let fn = () => - ParserFn(dm({ hitData: { not_key: 123 } }), "file/json:batch-manual", logger); + let fn = () => ParserFn(dm({ hitData: { not_key: 123 } }), "file/batch-manual", logger); t.throws(fn, mockErr("body[0].hitData | Invalid Key not_key")); let fn2 = () => - ParserFn(dm({ hitData: { pgreat: "123" } }), "file/json:batch-manual", logger); + ParserFn(dm({ hitData: { pgreat: "123" } }), "file/batch-manual", logger); t.throws( fn2, @@ -461,12 +458,11 @@ t.test("#ParserFn", (t) => { }); t.test("Invalid HitMeta", (t) => { - let fn = () => - ParserFn(dm({ hitMeta: { not_key: 123 } }), "file/json:batch-manual", logger); + let fn = () => ParserFn(dm({ hitMeta: { not_key: 123 } }), "file/batch-manual", logger); t.throws(fn, mockErr("body[0].hitMeta | Unexpected")); - let fn2 = () => ParserFn(dm({ hitMeta: { bp: -1 } }), "file/json:batch-manual", logger); + let fn2 = () => ParserFn(dm({ hitMeta: { bp: -1 } }), "file/batch-manual", logger); t.throws(fn2, mockErr("body[0].hitMeta.bp | Expected a positive integer")); diff --git a/server/src/score-import/import-types/file/eamusement-iidx-csv/converter.test.ts b/server/src/score-import/import-types/file/eamusement-iidx-csv/converter.test.ts index bd3b67dc9..0188805b2 100644 --- a/server/src/score-import/import-types/file/eamusement-iidx-csv/converter.test.ts +++ b/server/src/score-import/import-types/file/eamusement-iidx-csv/converter.test.ts @@ -21,7 +21,7 @@ const DryScorePrudence = { service: p.equalTo("e-amusement"), game: p.equalTo("iidx"), comment: "null", - importType: p.equalTo("file/csv:eamusement-iidx"), + importType: p.equalTo("file/eamusement-iidx-csv"), timeAchieved: p.equalTo(Date.parse("Tue, 27 Apr 2021 21:35:35 GMT")), scoreMeta: {}, scoreData: { @@ -198,7 +198,7 @@ t.test("#EamScoreConverter", async (t) => { err, new KTDataNotFoundFailure( `Could not find chart for 5.1.1. (SP LEGGENDARIA [v27])`, - "file/csv:eamusement-iidx", + "file/eamusement-iidx-csv", data, converterContext ), diff --git a/server/src/test-utils/mock-db/sessions.json b/server/src/test-utils/mock-db/sessions.json index 1226c05b3..a01b5876c 100644 --- a/server/src/test-utils/mock-db/sessions.json +++ b/server/src/test-utils/mock-db/sessions.json @@ -1,7 +1,7 @@ [ { "userID": 1, - "importType": "file/csv:eamusement-iidx", + "importType": "file/eamusement-iidx-csv", "name": "adjective1 adjective2 noun1", "sessionID": "Qe7b00261b1d3ba8e5c9ee4e76e77ea9f07d9493b", "desc": null,