Skip to content

Commit

Permalink
Add more tests for reset script (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesu committed Oct 26, 2020
1 parent eb93a64 commit 3b80fb9
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion test/import-reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,44 @@ describe("Import and Reset Script", () => {
assert.strictEqual(results.length, lengthBefore - uris.length)
})

const abortMessageForNoEntities = "Did not find any entities to be deleted, aborting"

it("should fail when -s and -c are given", async () => {
try {
await exec("yes | NODE_ENV=test ./bin/reset.js -s a:b -c c:d")
assert.fail("Expected exec to fail.")
} catch (error) {
assert(!error.stderr.includes(abortMessageForNoEntities))
}
})

it("should fail when -s is used with type other than concepts", async () => {
try {
await exec("yes | NODE_ENV=test ./bin/reset.js -s a:b -t mappings")
assert.fail("Expected exec to fail.")
} catch (error) {
assert(!error.stderr.includes(abortMessageForNoEntities))
}
})

it("should fail when -c is used with type other than mappings", async () => {
try {
await exec("yes | NODE_ENV=test ./bin/reset.js -c c:d -t concepts")
assert.fail("Expected exec to fail.")
} catch (error) {
assert(!error.stderr.includes(abortMessageForNoEntities))
}
})

it("should fail when -s is used with URI", async () => {
try {
await exec("yes | NODE_ENV=test ./bin/reset.js -s a:b c:d")
assert.fail("Expected exec to fail.")
} catch (error) {
assert(!error.stderr.includes(abortMessageForNoEntities))
}
})

it("should clear the whole database", async () => {
// Clear database
await exec("yes | NODE_ENV=test ./bin/reset.js")
Expand All @@ -219,7 +257,7 @@ describe("Import and Reset Script", () => {
await exec("yes | NODE_ENV=test ./bin/reset.js")
assert.fail("Expected reset script to fail if there are no entities to delete.")
} catch (error) {
// Ignore error
assert(error.stderr.includes(abortMessageForNoEntities))
}
})

Expand Down

0 comments on commit 3b80fb9

Please # to comment.