当前位置: 首页>>代码示例>>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;未经允许,请勿转载。