From f60caf11663e013de45f49d6137fbeb1f6088cee Mon Sep 17 00:00:00 2001 From: Tessa Walsh Date: Mon, 25 Sep 2023 17:43:21 -0400 Subject: [PATCH] Add tests --- tests/seeds.test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/seeds.test.js diff --git a/tests/seeds.test.js b/tests/seeds.test.js new file mode 100644 index 000000000..763cc4ab4 --- /dev/null +++ b/tests/seeds.test.js @@ -0,0 +1,19 @@ +import child_process from "child_process"; + +test("ensure one invalid seed doesn't end crawl unless failOnFailedSeed is set", async () => { + child_process.execSync("docker run -v $PWD/test-crawls:/crawls webrecorder/browsertrix-crawler crawl --url https://www.iana.org/ --url example.com/invalid-seed --generateWACZ --collection invalidseed"); + + try { + child_process.execSync("docker run -v $PWD/test-crawls:/crawls webrecorder/browsertrix-crawler crawl --url https://www.iana.org/ --url example.com/invalid-seed --generateWACZ --collection failseed --failOnFailedSeed"); + } catch (e) { + expect(e.status).toBe(17); + } +}); + +test("ensure crawl fails if no valid seeds are passed", async () => { + try { + child_process.execSync("docker run -v $PWD/test-crawls:/crawls webrecorder/browsertrix-crawler crawl --url iana.org/ --url example.com/invalid-seed --generateWACZ --collection allinvalidseeds"); + } catch (e) { + expect(e.status).toBe(17); + } +});