當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。