You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are trying to write tests with the TaskMockRunner. For the most part we don't need any commands mocked.
Our extension in tests using toolLib.downloadTool to download a zip file, and then toolLib.extractZip to extract to a designated directory.
Under the covers the unzip task calls exec, which when used with the TaskMockRunner expects it to be mocked with an answer.
We could do this normally for other commands, however toolLib.downloadTool downloads to a temp directory with a dynamic name, that cannot be staticly defined at test time:
let tmr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);
let mock: ma.MockAnswers = new ma.MockAnswers();
// not gonna fly, path is dynamic
const answers = {
"exec": {
"/usr/bin/unzip .test/tmp/6bb7bc61-bf6c-4187-9cdd-8ddfd34d58a4": {
"code": 0,
"stdout": "mock unzip stdout here",
"stderr": "mock unzip stderr here"
}
}
}
mock.initialize(answers)
tmr.setAnswers(answers)
tmr.run();
Under the covers unzip calls exec which expects to be mocked in test.
Expected behaviour
toolLib.extractZip can be used with TaskMockRunner without needing to specify a mock answer for the exec it makes.
Actual behaviour
tests that run from the TaskMockRunner cannot call toolLib.extractZip without providing exact mock answers.
Steps to reproduce
Logs
The text was updated successfully, but these errors were encountered:
Environment
azure-pipelines-task-lib version: 4.9.0
Issue Description
We are trying to write tests with the
TaskMockRunner
. For the most part we don't need any commands mocked.Our extension in tests using
toolLib.downloadTool
to download a zip file, and thentoolLib.extractZip
to extract to a designated directory.Under the covers the unzip task calls
exec
, which when used with the TaskMockRunner expects it to be mocked with an answer.We could do this normally for other commands, however
toolLib.downloadTool
downloads to a temp directory with a dynamic name, that cannot be staticly defined at test time:Under the covers unzip calls exec which expects to be mocked in test.
Expected behaviour
toolLib.extractZip
can be used withTaskMockRunner
without needing to specify a mock answer for the exec it makes.Actual behaviour
tests that run from the TaskMockRunner cannot call
toolLib.extractZip
without providing exact mock answers.Steps to reproduce
Logs
The text was updated successfully, but these errors were encountered: