-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add workingDirectory support * fix typo
- Loading branch information
1 parent
ccc1a97
commit e5a6ad6
Showing
7 changed files
with
79 additions
and
3 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import * as task from "azure-pipelines-task-lib/task" | ||
import * as tool from "azure-pipelines-tool-lib/tool" | ||
import * as fs from "fs" | ||
import * as os from "os" | ||
import * as path from "path" | ||
|
||
import { run } from "../src/index" | ||
import * as scanner from "../src/scanner" | ||
import { BoostParams } from "../src/params" | ||
|
||
const INITIAL_ENV = process.env | ||
|
||
jest.mock("../src/scanner") | ||
|
||
beforeEach(async () => { | ||
const tmpdir = await fs.promises.mkdtemp( | ||
path.resolve(os.tmpdir(), "boostsec-scanner-azure") | ||
) | ||
|
||
process.env = { | ||
TMPDIR: tmpdir, | ||
} | ||
process.chdir = jest.fn() | ||
}) | ||
|
||
afterEach(async () => { | ||
jest.clearAllMocks() | ||
jest.resetModules() | ||
jest.restoreAllMocks() | ||
|
||
if (process.env.TMPDIR !== undefined) { | ||
await fs.promises.rm(process.env.TMPDIR, { recursive: true, force: true }) | ||
} | ||
|
||
process.env = INITIAL_ENV | ||
}) | ||
|
||
describe("run", () => { | ||
test("run ignores workingDirectory by default", async () => { | ||
await run() | ||
|
||
expect(process.chdir).not.toHaveBeenCalled() | ||
expect(scanner.downloadCLI).toHaveBeenCalled() | ||
expect(scanner.executeCLI).toHaveBeenCalled() | ||
}) | ||
|
||
test("run changes workingDirectory", async () => { | ||
process.env.BOOST_WORKING_DIRECTORY = "/tmp" | ||
|
||
await run() | ||
|
||
expect(process.chdir).toHaveBeenCalledWith("/tmp") | ||
expect(scanner.downloadCLI).toHaveBeenCalled() | ||
expect(scanner.executeCLI).toHaveBeenCalled() | ||
}) | ||
}) |
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
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