UNPKG

@tiberriver256/mcp-server-azure-devops

Version:

Azure DevOps reference server for the Model Context Protocol (MCP)

85 lines 3.86 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const feature_1 = require("./feature"); const feature_2 = require("../list-pipelines/feature"); const test_helpers_1 = require("../../../shared/test/test-helpers"); const shouldSkip = (0, test_helpers_1.shouldSkipIntegrationTest)(); const projectId = process.env.AZURE_DEVOPS_DEFAULT_PROJECT || ''; const hasProjectId = Boolean(projectId); const describeOrSkip = !shouldSkip && hasProjectId ? describe : describe.skip; describeOrSkip('triggerPipeline integration', () => { let connection; let existingPipelineId; beforeAll(async () => { // Get a real connection using environment variables const testConnection = await (0, test_helpers_1.getTestConnection)(); if (!testConnection) { throw new Error('Connection should be available when integration tests are enabled'); } connection = testConnection; // Try to get an existing pipeline ID for testing const pipelines = await (0, feature_2.listPipelines)(connection, { projectId }); const pipelineId = pipelines[0]?.id; if (!pipelineId) { throw new Error('No pipelines found for triggerPipeline tests'); } existingPipelineId = pipelineId; }); test('should trigger a pipeline run', async () => { // Arrange - prepare options for running the pipeline const options = { projectId, pipelineId: existingPipelineId, // Use previewRun mode to avoid actually triggering pipelines during tests previewRun: true, }; // Act - trigger the pipeline const run = await (0, feature_1.triggerPipeline)(connection, options); // Assert - verify the response expect(run).toBeDefined(); // Run ID should be present expect(run.id).toBeDefined(); expect(typeof run.id).toBe('number'); // Pipeline reference should match the pipeline we triggered expect(run.pipeline?.id).toBe(existingPipelineId); // URL should exist and point to the run expect(run.url).toBeDefined(); expect(run.url).toContain('_apis/pipelines'); }); test('should trigger with custom branch', async () => { // Arrange - prepare options with a branch const options = { projectId, pipelineId: existingPipelineId, branch: 'main', // Use the main branch // Use previewRun mode to avoid actually triggering pipelines during tests previewRun: true, }; // Act - trigger the pipeline with custom options const run = await (0, feature_1.triggerPipeline)(connection, options); // Assert - verify the response expect(run).toBeDefined(); expect(run.id).toBeDefined(); // Resources should include the specified branch expect(run.resources?.repositories?.self?.refName).toBe('refs/heads/main'); }); test('should handle non-existent pipeline', async () => { // Use a very high ID that is unlikely to exist const nonExistentPipelineId = 999999; try { // Attempt to trigger a pipeline that shouldn't exist await (0, feature_1.triggerPipeline)(connection, { projectId, pipelineId: nonExistentPipelineId, }); // If we reach here without an error, we'll fail the test fail('Expected triggerPipeline to throw an error for non-existent pipeline'); } catch (error) { // We expect an error, so this test passes if we get here expect(error).toBeDefined(); // Note: the exact error type might vary depending on the API response } }); }); //# sourceMappingURL=feature.spec.int.js.map