当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript mock-task.setAnswers函数代码示例

本文整理汇总了TypeScript中vsts-task-lib/mock-task.setAnswers函数的典型用法代码示例。如果您正苦于以下问题:TypeScript setAnswers函数的具体用法?TypeScript setAnswers怎么用?TypeScript setAnswers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setAnswers函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

it('adds base environment to path successfully', function () {
    mockTask.setAnswers({
        which: {
            'conda': '/miniconda/bin/conda'
        },
        exec: {
            '/miniconda/bin/conda info --base': {
                code: 0,
                stdout: '/base/environment'
            }
        },
        checkPath: {
            '/miniconda/bin/conda': true
        }
    });

    mockery.registerMock('vsts-task-lib/task', mockTask);

    const prependPathSafe = sinon.spy();
    mockery.registerMock('./toolutil', {
        prependPathSafe
    });

    const uut = reload('../conda_internal');
    uut.addBaseEnvironmentToPath(Platform.Linux);

    assert(prependPathSafe.calledOnceWithExactly(path.join('/base/environment', 'bin')));
});
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:28,代码来源:L0_conda_internal.ts

示例2: it

it('finds the Conda installation with the CONDA variable', function () {
    const existsSync = sinon.stub();
    const statSync = sinon.stub();

    mockery.registerMock('fs', {
        existsSync,
        statSync
    });

    mockTask.setAnswers({
        which: {
        }
    });

    const getVariable = sinon.stub();
    getVariable.withArgs('CONDA').returns('path-to-conda');
    getVariable.withArgs('Agent.ToolsDirectory').returns('path-to-tools');

    mockery.registerMock('vsts-task-lib/task', Object.assign({}, mockTask, {
        getVariable
    }));

    mockery.registerMock('vsts-task-tool-lib/tool', {});

    { // executable exists and is a file
        existsSync.returns(true);
        statSync.returns({
            isFile: () => true
        });

        const uut = reload('../conda_internal');

        assert.strictEqual(uut.findConda(Platform.Linux), 'path-to-conda');
        assert.strictEqual(uut.findConda(Platform.MacOS), 'path-to-conda');
        assert.strictEqual(uut.findConda(Platform.Windows), 'path-to-conda');
    }
    { // `conda` executable does not exist
        existsSync.returns(false);
        const uut = reload('../conda_internal');

        assert.strictEqual(uut.findConda(Platform.Linux), null);
        assert.strictEqual(uut.findConda(Platform.MacOS), null);
        assert.strictEqual(uut.findConda(Platform.Windows), null);
    }
    { // `conda` exists but is not a file
        existsSync.returns(true);
        statSync.returns({
            isFile: () => false
        });

        const uut = reload('../conda_internal');

        assert.strictEqual(uut.findConda(Platform.Linux), null);
        assert.strictEqual(uut.findConda(Platform.MacOS), null);
        assert.strictEqual(uut.findConda(Platform.Windows), null);
    }
});
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:57,代码来源:L0_conda_internal.ts

示例3: run

    public run() {
        mockery.enable({warnOnUnregistered: false});
        var tlm = require('vsts-task-lib/mock-task');
        if (this._answers) {
            tlm.setAnswers(this._answers);
        }
        mockery.registerMock('vsts-task-lib/task', tlm);

        // run it
        require(this._taskPath);
    }
开发者ID:tspascoal,项目名称:vsts-task-lib,代码行数:11,代码来源:mock-run.ts

示例4: function

        "msdeploy": true
    },
    "exec": {
        "msdeploy -verb:getParameters -source:package=\'webAppPkg.zip\'": {
            "code": 0,
            "stdout": "Executed Successfully"
        }
    },
    "rmRF": {
        "DefaultWorkingDirectory\\parameter.xml": {
            "success" : true
        }
    }
};

tlm.setAnswers(a);

mockery.registerMock('vsts-task-lib/task', tlm);

mockery.registerMock('fs', {
    createWriteStream: function (filePath, options) {
        console.log("inside createWriteStream function");
        return {
            "isWriteStreamObj": true,
            "write": function(message) {
                console.log(message);
            }
        }; 
    },
    openSync: function (fd, options) {
        console.log("inside openSync function");
开发者ID:ReneSchumacher,项目名称:VSTS-Tasks,代码行数:31,代码来源:L0MSDeployUtility.ts

示例5: function

        "msdeploy": true
    },
    "exec": {
        "msdeploy -verb:getParameters -source:package=\'webAppPkg.zip\'": {
            "code": 1,
            "stderr": "msdeploy failed to execute successfully"
        }
    },
    "rmRF": {
        "DefaultWorkingDirectory\\parameter.xml": {
            "success" : true
        }
    }
};

tlm.setAnswers(ans);

mockery.registerMock('vsts-task-lib/task', tlm);

mockery.registerMock('fs', {
    createWriteStream: function (filePath, options) {
        console.log("inside createWriteStream function");
        return {
            "isWriteStreamObj": true,
            "write": function(message) {
                console.log(message);
            }
        }; 
    },
    openSync: function (fd, options) {
        console.log("inside openSync function");
开发者ID:ReneSchumacher,项目名称:VSTS-Tasks,代码行数:31,代码来源:L0MSDeployUtilityFail.ts


注:本文中的vsts-task-lib/mock-task.setAnswers函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。