本文整理匯總了TypeScript中vsts-task-lib/mock-run.TaskMockRunner.setInput方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript TaskMockRunner.setInput方法的具體用法?TypeScript TaskMockRunner.setInput怎麽用?TypeScript TaskMockRunner.setInput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vsts-task-lib/mock-run.TaskMockRunner
的用法示例。
在下文中一共展示了TaskMockRunner.setInput方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: 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", "Connect");
tmr.setInput("NICDetection", "AutoDetectNic");
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",
示例2:
import * as MockRun from "vsts-task-lib/mock-run";
import * as Path from "path";
let taskPath: string = Path.join(__dirname, "../../../Tasks/AddBuildTag/addBuildTag.js");
let taskMock: MockRun.TaskMockRunner = new MockRun.TaskMockRunner(taskPath);
taskMock.setInput("Tag", "BuildTagged");
taskMock.run();
示例3:
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();
示例4: 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",
示例5:
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();
示例6: 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();
示例7: 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,
});
示例8: 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));
tmr.setInput("NotifyServiceOwners", "true");
tmr.setInput("NotifyEmails", "abc@d.com; ; ; def@g.com ;");
nock("http://example.com", {
reqheaders: {
'authorization': 'Bearer accessToken',
"accept": "application/json",
"user-agent": "TFS_useragent"
}
})
.get(/\/subscriptions\/sId\/resourceGroups\/testRg\/providers\/Microsoft.insights\/alertrules\/Rule1/)
.query({"api-version": "2016-03-01"})
.reply(200, {
location: "alertrulelocation",
properties: {
condition: {
dataSource: {
"$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleMetricDataSource, Microsoft.WindowsAzure.Management.Mon.Client",
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
示例9:
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("bowerjson", "bower.json");
tmr.setAnswers({
which: {
"bower": "/bin/bower"
},
exist: {
"/bin/bower": true
},
checkPath: {
"bower.json": true
},
exec: {
"/bin/bower install --config.interactive=false": {
code: 0,
stdout: "[MOCK] Bower installation done!"
}
}
});
tmr.run();