本文整理匯總了TypeScript中vsts-task-lib/mock-run.TaskMockRunner類的典型用法代碼示例。如果您正苦於以下問題:TypeScript TaskMockRunner類的具體用法?TypeScript TaskMockRunner怎麽用?TypeScript TaskMockRunner使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了TaskMockRunner類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: require
import * as path from "path";
import * as mocks from "./L0Mocks";
import { TaskMockRunner } from "vsts-task-lib/mock-run";
var nock = require("nock");
let tmr: TaskMockRunner = new TaskMockRunner(path.join(__dirname, '..', 'azuremonitoralerts.js'));
tmr.setInput("ConnectedServiceName", "azureRMSpn");
tmr.setInput("ResourceGroupName", "testRg");
tmr.setInput("ResourceType", "testResource.provider/type");
tmr.setInput("ResourceName", "testResourceName");
tmr.setInput("AlertRules", JSON.stringify(mocks.mockAlertRules));
nock("https://login.windows.net", {
reqheaders: {
"content-type": "application/x-www-form-urlencoded; charset=utf-8"
}
})
.post("/tenantId/oauth2/token/")
.reply(200, {
access_token: "accessToken"
}).persist();
nock("http://example.com", {
reqheaders: {
'authorization': 'Bearer accessToken',
"accept": "application/json",
"user-agent": "TFS_useragent"
}
})
.get(/\/subscriptions\/sId\/resourceGroups\/testRg\/providers\/Microsoft.insights\/alertrules\/*/)
示例2: require
import * as ma from 'vsts-task-lib/mock-answer';
import * as tmrm from 'vsts-task-lib/mock-run';
import * as path from 'path';
let taskPath = path.join(__dirname, '..', 'nlbtask.js');
let tmr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);
tmr.setInput('ConnectedServiceName', 'AzureRMSpn');
tmr.setInput("ResourceGroupName", "testRG");
tmr.setInput("LoadBalancer", "testLB");
tmr.setInput("Action", "Disconnect");
process.env["ENDPOINT_AUTH_AzureRMSpn"] = "{\"parameters\":{\"serviceprincipalid\":\"spId\",\"serviceprincipalkey\":\"spKey\",\"tenantid\":\"tenant\"},\"scheme\":\"ServicePrincipal\"}";
process.env["ENDPOINT_DATA_AzureRMSpn_SUBSCRIPTIONNAME"] = "sName";
process.env["ENDPOINT_DATA_AzureRMSpn_SUBSCRIPTIONID"] = "sId";
process.env["AZURE_HTTP_USER_AGENT"] = "TFS_useragent";
process.env["SYSTEM_DEFAULTWORKINGDIRECTORY"] = "DefaultWorkingDirectory";
process.env["COMPUTERNAME"] = "test-vm";
var tl = require('vsts-task-lib/mock-task');
tmr.registerMock('./nlbazureutility', {
getNetworkInterfacesInRG: function(SPN, endpointUrl, resourceGroupName) {
return [
{
"name": "test-nic1",
"id": "test-nic1-id",
"properties": {
"provisioningState": "Succeeded",
"ipConfigurations": [{
"name": "test-ipconfig1",
"id":"test-ipconfig1-id",
示例3:
import * as MockRun from "vsts-task-lib/mock-run";
import * as Path from "path";
let taskPath: string = Path.join(__dirname, "../../../Tasks/SetVariable/setVariable.js");
let taskMock: MockRun.TaskMockRunner = new MockRun.TaskMockRunner(taskPath);
taskMock.setInput("name", "TaskVariable");
taskMock.setInput("value", "AnyValue")
taskMock.run();
示例4: TaskMockRunner
import * as path from 'path';
import { TaskMockRunner } from 'vsts-task-lib/mock-run';
const taskPath = path.join(__dirname, '..', 'main.js');
const taskRunner = new TaskMockRunner(taskPath);
taskRunner.setInput('versionSpec', '3.x');
taskRunner.setInput('addToPath', 'false');
taskRunner.setInput('architecture', 'x64');
// Mock vsts-task-tool-lib
const toolPath = path.join('/', 'Python', '3.6.4', 'x64');
taskRunner.registerMock('vsts-task-tool-lib/tool', {
findLocalTool: () => toolPath
});
taskRunner.run();
示例5: TaskMockRunner
import * as path from 'path';
import * as mockery from 'mockery';
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,
});
示例6:
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();
示例7: 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();
示例8: TaskMockRunner
import * as path from 'path';
import { TaskMockRunner } from 'vsts-task-lib/mock-run';
const taskPath = path.join(__dirname, '..', 'main.js');
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
}
});
示例9:
import * as MockRun from "vsts-task-lib/mock-run";
import * as Path from "path";
let taskPath: string = Path.join(__dirname, "../../../Tasks/AttachSummaryMarkdown/AttachSummaryMarkdown.js");
let taskMock: MockRun.TaskMockRunner = new MockRun.TaskMockRunner(taskPath);
taskMock.setInput("SectionName", "CustomSection");
taskMock.run();
示例10: TaskMockRunner
import * as path from 'path';
import { TaskMockRunner } from 'vsts-task-lib/mock-run';
const taskPath = path.join(__dirname, '..', 'main.js');
const taskRunner = new TaskMockRunner(taskPath);
taskRunner.setInput('versionSpec', '3.x');
taskRunner.setInput('addToPath', 'false');
taskRunner.setInput('architecture', 'x64');
// Mock vsts-task-tool-lib
taskRunner.registerMock('vsts-task-tool-lib/tool', {
findLocalTool: () => null,
findLocalToolVersions: () => ['2.6.0', '2.7.13']
});
taskRunner.run();