Created
November 28, 2021 01:13
-
-
Save dorner/edf8ffe9b7285b06d2ed0f107c1ad0b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs") | |
const path = require("path") | |
const files = fs.readdirSync(process.env.CALL_DIR) | |
const outputs = `${process.env.CALL_DIR}/../outputs` | |
if (!fs.existsSync(outputs)) { | |
console.log(process.cwd()) | |
console.log("outputs directory does not exist - use UPDATE_SNAPSHOTS=1 to create") | |
process.exit(1) | |
} | |
const expectedFiles = fs.readdirSync(outputs) | |
let foundError = false; | |
const extraFiles = files.filter(x => x.endsWith(".calls") && !expectedFiles.includes(x)); | |
if (extraFiles.length > 0) { | |
foundError = true; | |
console.log(`The following files were output but there are no expected outputs for them! ${extraFiles.join(", ")}`) | |
} | |
const missingFiles = expectedFiles.filter(x => x.endsWith(".calls") && !files.includes(x)) | |
if (missingFiles.length > 0) { | |
foundError = true; | |
console.log(`The following files were expected to be output but weren't! ${missingFiles.join(", ")}`) | |
} | |
files.forEach((file) => { | |
if (file.endsWith('.calls') || file === 'full-output.txt') { | |
const firstFile = fs.readFileSync(`${process.env.CALL_DIR}/${file}`); | |
if (!fs.existsSync(`${outputs}/${path.basename(file)}`)) { | |
console.log(`${outputs}/${path.basename(file)} does not exist!`) | |
foundError = true | |
return; | |
} | |
const secondFile = fs.readFileSync(`${outputs}/${path.basename(file)}`) | |
if (!firstFile.equals(secondFile)) { | |
console.log(`${file} contents are not equal!`) | |
foundError = true | |
} | |
} | |
}) | |
process.exit(foundError ? 1 : 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bats | |
load ./shared | |
@test "default env variables" { | |
performTest "defaults" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment