diff --git a/tslib/storage/test/generate_assets.py b/tslib/storage/test/generate_assets.py index e4ee9ada..48e08a64 100644 --- a/tslib/storage/test/generate_assets.py +++ b/tslib/storage/test/generate_assets.py @@ -87,12 +87,13 @@ if __name__ == "__main__": ]: create_optuna_storage(storage) - # Add a broken line to the random position in the journal.log to test error handling + # Make a file including a broken line to the random position to test error handling + shutil.copyfile(os.path.join(BASE_DIR, "journal.log"), os.path.join(BASE_DIR, "journal-broken.log")) broken_line = ( '{"op_code": ..., "worker_id": "0000", "study_id": 0,' '"datetime_start": "2024-04-01T12:00:00.000000"}\n' ) - with open(os.path.join(BASE_DIR, "journal.log"), "r+") as f: + with open(os.path.join(BASE_DIR, "journal-broken.log"), "r+") as f: lines = f.readlines() lines.insert(random.randint(0, len(lines)), broken_line) f.truncate(0) diff --git a/tslib/storage/test/journal.test.mjs b/tslib/storage/test/journal.test.mjs index 130dba74..42e07133 100644 --- a/tslib/storage/test/journal.test.mjs +++ b/tslib/storage/test/journal.test.mjs @@ -15,7 +15,6 @@ describe("Test Journal File Storage", async () => { const studies = await Promise.all( studySummaries.map((_summary, index) => storage.getStudy(index)) ) - const errors = storage.getErrors() it("Check the study including Infinities", () => { const study = studies.find((s) => s.study_name === "single-inf") @@ -38,7 +37,14 @@ describe("Test Journal File Storage", async () => { } }) - it("Check the parsing errors", () => { + it("Check the parsing errors", async () => { + const blob = await openAsBlob( + path.resolve(".", "test", "asset", "journal-broken.log") + ) + const buf = await blob.arrayBuffer() + const storage = new mut.JournalFileStorage(buf) + const errors = storage.getErrors() + assert.strictEqual(errors.length, 1) assert.strictEqual( errors[0].message,