Skip to content

Commit

Permalink
Get broken tests down to 6
Browse files Browse the repository at this point in the history
  • Loading branch information
winstliu committed Oct 1, 2024
1 parent df84c7a commit 7ee5891
Showing 1 changed file with 5 additions and 25 deletions.
30 changes: 5 additions & 25 deletions test/pipelinesTests/yamlvalidation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,34 +93,23 @@ variables:
});

it('validates pipelines with unfinished conditional variable checks', async function () {
// Note: the real purpose of this test is to ensure we don't throw,
// but I can't figure out how to assert that yet.
// result.length can be whatever, as long as we get to that point :).
const content = `
variables:
\${{ if eq(variables['Build.SourceBranch'], 'main') }}:
`;
const result = await parseSetup(content);
assert.equal(result.length, 0);
await assert.doesNotReject(() => parseSetup(content));
});

it('validates pipelines with unfinished conditionally-inserted variables', async function () {
// Note: the real purpose of this test is to ensure we don't throw,
// but I can't figure out how to assert that yet.
// result.length can be whatever, as long as we get to that point :).
const content = `
variables:
\${{ if eq(variables['Build.SourceBranch'], 'main') }}:
j
`;
const result = await parseSetup(content);
assert.equal(result.length, 0);
await assert.doesNotReject(() => parseSetup(content));
});

it('validates pipelines with multiple levels of expression nesting', async function () {
// Note: the real purpose of this test is to ensure we don't throw,
// but I can't figure out how to assert that yet.
// result.length can be whatever, as long as we get to that point :).
const content = `
steps:
- \${{ each step in parameters.buildSteps }}:
Expand All @@ -130,27 +119,19 @@ steps:
\${{ if eq(pair.value, 'CmdLine@2') }}:
'\${{ pair.value }}': error
`;
const result = await parseSetup(content);
assert.equal(result.length, 0);
await assert.doesNotReject(() => parseSetup(content));
});

it('validates pipelines that has an object with a dynamic key and scalar value as the first property', async function () {
// Note: the real purpose of this test is to ensure we don't throw,
// but I can't figure out how to assert that yet.
// result.length can be whatever, as long as we get to that point :).
const content = `
steps:
- \${{ each shorthand in parameters.taskShorthands }}:
- \${{ shorthand }}: echo 'Hi'
`;
const result = await parseSetup(content);
assert.equal(result.length, 2);
await assert.doesNotReject(() => parseSetup(content));
});

it('validates incorrectly-indented pipelines that look like they have an array property', async function () {
// Note: the real purpose of this test is to ensure we don't throw,
// but I can't figure out how to assert that yet.
// result.length can be whatever, as long as we get to that point :).
const content = `
steps:
- task: PowerShellOnTargetMachines@3
Expand All @@ -160,7 +141,6 @@ steps:
[System.Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") | Out-Null
CommunicationProtocol: Http);
`;
const result = await parseSetup(content);
assert.equal(result.length, 4);
await assert.doesNotReject(() => parseSetup(content));
});
});

0 comments on commit 7ee5891

Please sign in to comment.