本文整理汇总了TypeScript中vsts-task-lib/mock-task.setAnswers函数的典型用法代码示例。如果您正苦于以下问题:TypeScript setAnswers函数的具体用法?TypeScript setAnswers怎么用?TypeScript setAnswers使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setAnswers函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('adds base environment to path successfully', function () {
mockTask.setAnswers({
which: {
'conda': '/miniconda/bin/conda'
},
exec: {
'/miniconda/bin/conda info --base': {
code: 0,
stdout: '/base/environment'
}
},
checkPath: {
'/miniconda/bin/conda': true
}
});
mockery.registerMock('vsts-task-lib/task', mockTask);
const prependPathSafe = sinon.spy();
mockery.registerMock('./toolutil', {
prependPathSafe
});
const uut = reload('../conda_internal');
uut.addBaseEnvironmentToPath(Platform.Linux);
assert(prependPathSafe.calledOnceWithExactly(path.join('/base/environment', 'bin')));
});
示例2: it
it('finds the Conda installation with the CONDA variable', function () {
const existsSync = sinon.stub();
const statSync = sinon.stub();
mockery.registerMock('fs', {
existsSync,
statSync
});
mockTask.setAnswers({
which: {
}
});
const getVariable = sinon.stub();
getVariable.withArgs('CONDA').returns('path-to-conda');
getVariable.withArgs('Agent.ToolsDirectory').returns('path-to-tools');
mockery.registerMock('vsts-task-lib/task', Object.assign({}, mockTask, {
getVariable
}));
mockery.registerMock('vsts-task-tool-lib/tool', {});
{ // executable exists and is a file
existsSync.returns(true);
statSync.returns({
isFile: () => true
});
const uut = reload('../conda_internal');
assert.strictEqual(uut.findConda(Platform.Linux), 'path-to-conda');
assert.strictEqual(uut.findConda(Platform.MacOS), 'path-to-conda');
assert.strictEqual(uut.findConda(Platform.Windows), 'path-to-conda');
}
{ // `conda` executable does not exist
existsSync.returns(false);
const uut = reload('../conda_internal');
assert.strictEqual(uut.findConda(Platform.Linux), null);
assert.strictEqual(uut.findConda(Platform.MacOS), null);
assert.strictEqual(uut.findConda(Platform.Windows), null);
}
{ // `conda` exists but is not a file
existsSync.returns(true);
statSync.returns({
isFile: () => false
});
const uut = reload('../conda_internal');
assert.strictEqual(uut.findConda(Platform.Linux), null);
assert.strictEqual(uut.findConda(Platform.MacOS), null);
assert.strictEqual(uut.findConda(Platform.Windows), null);
}
});
示例3: run
public run() {
mockery.enable({warnOnUnregistered: false});
var tlm = require('vsts-task-lib/mock-task');
if (this._answers) {
tlm.setAnswers(this._answers);
}
mockery.registerMock('vsts-task-lib/task', tlm);
// run it
require(this._taskPath);
}
示例4: function
"msdeploy": true
},
"exec": {
"msdeploy -verb:getParameters -source:package=\'webAppPkg.zip\'": {
"code": 0,
"stdout": "Executed Successfully"
}
},
"rmRF": {
"DefaultWorkingDirectory\\parameter.xml": {
"success" : true
}
}
};
tlm.setAnswers(a);
mockery.registerMock('vsts-task-lib/task', tlm);
mockery.registerMock('fs', {
createWriteStream: function (filePath, options) {
console.log("inside createWriteStream function");
return {
"isWriteStreamObj": true,
"write": function(message) {
console.log(message);
}
};
},
openSync: function (fd, options) {
console.log("inside openSync function");
示例5: function
"msdeploy": true
},
"exec": {
"msdeploy -verb:getParameters -source:package=\'webAppPkg.zip\'": {
"code": 1,
"stderr": "msdeploy failed to execute successfully"
}
},
"rmRF": {
"DefaultWorkingDirectory\\parameter.xml": {
"success" : true
}
}
};
tlm.setAnswers(ans);
mockery.registerMock('vsts-task-lib/task', tlm);
mockery.registerMock('fs', {
createWriteStream: function (filePath, options) {
console.log("inside createWriteStream function");
return {
"isWriteStreamObj": true,
"write": function(message) {
console.log(message);
}
};
},
openSync: function (fd, options) {
console.log("inside openSync function");