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


TypeScript TaskMockRunner.setAnswers方法代碼示例

本文整理匯總了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!"
        }
    }
});
開發者ID:touchifyapp,項目名稱:vsts-bower,代碼行數:32,代碼來源:14-find-in-npm-prefix.ts

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

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

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

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

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

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


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