當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript mock-run.TaskMockRunner類代碼示例

本文整理匯總了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\/*/)
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:31,代碼來源:L0AddAlertRuleFails.ts

示例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",
開發者ID:DarqueWarrior,項目名稱:vsts-tasks,代碼行數:31,代碼來源:L0TaskFailSetNetworkInterface.ts

示例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();
開發者ID:andremarques023,項目名稱:vsts-extensions,代碼行數:8,代碼來源:whenValueIsSetItShouldSetValue.ts

示例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();
開發者ID:bleissem,項目名稱:vsts-tasks,代碼行數:18,代碼來源:L0SucceedsWhenVersionIsFound.ts

示例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,
});
開發者ID:shubham90,項目名稱:vsts-tasks,代碼行數:31,代碼來源:L0CreateEnvironment.ts

示例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();
開發者ID:touchifyapp,項目名稱:vsts-bower,代碼行數:28,代碼來源:21-no-bowerjson.ts

示例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();
開發者ID:bleissem,項目名稱:vsts-tasks,代碼行數:31,代碼來源:L0CondaNotFound.ts

示例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
    }
});
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:31,代碼來源:L0BaseEnvironment.ts

示例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();
開發者ID:andremarques023,項目名稱:vsts-extensions,代碼行數:7,代碼來源:whenMarkdownFilePathIsNotSetItShouldFail.ts

示例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();
開發者ID:bleissem,項目名稱:vsts-tasks,代碼行數:18,代碼來源:L0FailsWhenVersionIsMissing.ts


注:本文中的vsts-task-lib/mock-run.TaskMockRunner類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。