Skip to content

Commit

Permalink
try to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenWeatherford committed Mar 24, 2022
1 parent 16371a9 commit 2ae1ee2
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/vscode-bicep/src/test/e2e/createBicepConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ describe("bicep.createConfigFile", (): void => {
newConfigPath = newConfigPath!;

expect(path.basename(newConfigPath)).toBe("bicepconfig.json");
expect(fileExists(newConfigPath)).toBeTruthy();
if (!fileExists(newConfigPath)) {
throw new Error(`Expected file ${newConfigPath} to exist but it doesn't`);
}

expect(fileContains(newConfigPath, "rules")).toBeTruthy();
expect(fileIsValidJson(newConfigPath)).toBeTruthy();
Expand Down Expand Up @@ -77,12 +79,19 @@ describe("bicep.createConfigFile", (): void => {
});

function createUniqueTempFolder(filenamePrefix: string): string {
const tmp = os.tmpdir();
if (!fse.existsSync(tmp)) {
fse.mkdirSync(tmp);
const tempFolder = os.tmpdir();
if (!fse.existsSync(tempFolder)) {
console.log(`Creating ${tempFolder}`)
fse.mkdirSync(tempFolder);
console.log(`Created ${tempFolder}`)
}

const tempFolder = fse.mkdtempSync(path.join(tmp, filenamePrefix));
const tempSubfolder = fse.mkdtempSync(path.join(tempFolder, filenamePrefix));
if (!fse.existsSync(tempSubfolder)) {
console.log(`Creating ${tempSubfolder}`)
fse.mkdirSync(tempSubfolder);
console.log(`Created ${tempSubfolder}`)
}

return tempFolder;
return tempSubfolder;
}

0 comments on commit 2ae1ee2

Please sign in to comment.