本文整理汇总了TypeScript中vsts-task-lib/mock-run.TaskMockRunner.setAnswers方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TaskMockRunner.setAnswers方法的具体用法?TypeScript TaskMockRunner.setAnswers怎么用?TypeScript TaskMockRunner.setAnswers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vsts-task-lib/mock-run.TaskMockRunner
的用法示例。
在下文中一共展示了TaskMockRunner.setAnswers方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
tmr.setAnswers({
which: {
"bower": "/bin/bower",
"npm": "/bin/npm",
},
exist: {
"/bin/bower": false,
[RUNTIME_PATH_ABS]: false,
[NPM_GLOBAL_BOWER]: true
},
checkPath: {
"bower.json": true,
"/bin/npm": true,
"/bin/bower": false
},
exec: {
"/bin/npm prefix -g": {
code: 0,
stdout: NPM_GLOBAL_PREFIX
},
"/bin/npm install -g bower": {
code: 0,
stdout: "[MOCK] NPM installation done!"
},
[NPM_GLOBAL_BOWER + " install --config.interactive=false"]: {
code: 0,
stdout: "[MOCK] Bower installation done!"
}
}
});
示例2: TaskMockRunner
import { TaskMockRunner } from 'vsts-task-lib/mock-run';
const taskPath = path.join(__dirname, '..', 'main.js');
const taskRunner = new TaskMockRunner(taskPath);
taskRunner.setInput('createCustomEnvironment', 'true');
taskRunner.setInput('environmentName', 'test');
// Mock vsts-task-lib
taskRunner.setAnswers({
which: {
'conda': '/miniconda/bin/conda'
},
exec: {
'sudo /miniconda/bin/conda create --quiet --prefix /miniconda/envs/test --mkdir --yes': {
code: 0
},
'conda create --quiet --prefix \\miniconda\\envs\\test --mkdir --yes': {
code: 0
},
}
});
// Mock vsts-task-tool-lib
taskRunner.registerMock('vsts-task-tool-lib/tool', {
prependPath: () => undefined,
});
// Mock other dependencies
mockery.registerMock('fs', {
existsSync: () => false
示例3: TaskMockRunner
import * as path from 'path';
import * as sinon from 'sinon';
import { TaskMockRunner } from 'vsts-task-lib/mock-run';
const taskPath = path.join(__dirname, '..', 'main.js');
const taskRunner = new TaskMockRunner(taskPath);
taskRunner.setInput('environmentName', 'test');
// Mock vsts-task-lib
taskRunner.setAnswers({
which: {
}
});
const getVariable = sinon.stub();
getVariable.withArgs('CONDA').returns(undefined);
taskRunner.registerMock('vsts-task-lib/task', {
// `getVariable` is not supported by `TaskLibAnswers`
getVariable: getVariable
});
// Mock vsts-task-tool-lib
taskRunner.registerMock('vsts-task-tool-lib/tool', {
prependPath: () => undefined
});
taskRunner.run();
示例4:
import * as ma from "vsts-task-lib/mock-answer";
import * as tmrm from "vsts-task-lib/mock-run";
import * as path from "path";
const
TASK_PATH = path.join(__dirname, "..", "bower", "bowertask.js"),
tmr = new tmrm.TaskMockRunner(TASK_PATH);
tmr.setInput("command", "install");
tmr.setInput("bowerjson", "bower.json");
tmr.setAnswers({
which: {
"bower": "/bin/bower"
},
exist: {
"/bin/bower": true
},
exec: {
"/bin/bower install --config.interactive=false": {
code: 0,
stdout: "[MOCK] Bower installation done!"
}
}
});
tmr.run();
示例5: TaskMockRunner
import { TaskMockRunner } from 'vsts-task-lib/mock-run';
const taskPath = path.join(__dirname, '..', 'main.js');
const taskRunner = new TaskMockRunner(taskPath);
taskRunner.setInput('environmentName', 'test');
// Mock vsts-task-lib
taskRunner.setAnswers({
which: {
// 'conda': path.join('/', 'miniconda', 'bin', 'conda')
'conda': '/miniconda/bin/conda'
},
exec: {
'conda create --quiet --prefix /miniconda/envs/test --mkdir --yes': {
'code': 0
},
'conda create --quiet --prefix \\miniconda\\envs\\test --mkdir --yes': {
'code': 0
},
}
});
// Mock vsts-task-tool-lib
taskRunner.registerMock('vsts-task-tool-lib/tool', {
prependPath: () => undefined,
});
// Mock other dependencies
mockery.registerMock('fs', {
existsSync: () => false
示例6: TaskMockRunner
const taskRunner = new TaskMockRunner(taskPath);
taskRunner.setInput('packageSpecs', 'python=3');
taskRunner.setInput('installOptions', '--json');
// Mock vsts-task-lib
taskRunner.setAnswers({
which: {
'conda': '/miniconda/bin/conda'
},
exec: {
'sudo /miniconda/bin/conda install python=3 --quiet --yes --json': {
code: 0
},
'conda install python=3 --quiet --yes --json': {
code: 0
},
'/miniconda/bin/conda info --base': {
code: 0,
stdout: '/base/environment'
},
},
checkPath: {
'/miniconda/bin/conda': true
}
});
// Mock vsts-task-tool-lib
taskRunner.registerMock('vsts-task-tool-lib/tool', {
prependPath: () => undefined,
});
示例7:
import * as tmrm from "vsts-task-lib/mock-run";
import * as path from "path";
const
TASK_PATH = path.join(__dirname, "..", "bower", "bowertask.js"),
tmr = new tmrm.TaskMockRunner(TASK_PATH);
tmr.setInput("command", "install");
tmr.setInput("bowerjson", "bower.json");
tmr.setInput("arguments", "--arg1=val --arg2");
tmr.setAnswers({
which: {
"bower": "/bin/bower"
},
exist: {
"/bin/bower": true
},
checkPath: {
"bower.json": true
},
exec: {
"/bin/bower install --config.interactive=false --arg1=val --arg2": {
code: 0,
stdout: "[MOCK] Bower installation with arguments done!"
}
}
});
tmr.run();