Skip to content

Commit

Permalink
Code REview comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jabbera committed Dec 7, 2023
1 parent ef4d327 commit 6987e13
Showing 1 changed file with 131 additions and 141 deletions.
272 changes: 131 additions & 141 deletions lib/modules/manager/azure-pipelines/extract.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { codeBlock } from 'common-tags';
import { Fixtures } from '../../../../test/fixtures';
import { GlobalConfig } from '../../../config/global';
import { AzurePipelinesTasksDatasource } from '../../datasource/azure-pipelines-tasks';
Expand Down Expand Up @@ -184,19 +185,18 @@ describe('modules/manager/azure-pipelines/extract', () => {
});

it('should extract deployment jobs runonce', () => {
const res = extractPackageFile(
`
jobs:
- deployment: deployment_one
strategy:
runOnce:
deploy:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'`,
azurePipelinesFilename,
);
const packageFile = codeBlock`
jobs:
- deployment: deployment_one
strategy:
runOnce:
deploy:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
Expand All @@ -207,20 +207,19 @@ jobs:
});

it('should extract deployment jobs on failure', () => {
const res = extractPackageFile(
`
jobs:
- deployment: deployment_one
strategy:
runOnce:
on:
failure:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'`,
azurePipelinesFilename,
);
const packageFile = codeBlock`
jobs:
- deployment: deployment_one
strategy:
runOnce:
on:
failure:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
Expand All @@ -231,20 +230,19 @@ jobs:
});

it('should extract deployment jobs on success', () => {
const res = extractPackageFile(
`
jobs:
- deployment: deployment_one
strategy:
runOnce:
on:
success:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'`,
azurePipelinesFilename,
);
const packageFile = codeBlock`
jobs:
- deployment: deployment_one
strategy:
runOnce:
on:
success:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
Expand All @@ -255,19 +253,18 @@ jobs:
});

it('should extract deployment jobs postroute', () => {
const res = extractPackageFile(
`
jobs:
- deployment: deployment_one
strategy:
runOnce:
postRouteTraffic:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'`,
azurePipelinesFilename,
);
const packageFile = codeBlock`
jobs:
- deployment: deployment_one
strategy:
runOnce:
postRouteTraffic:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
Expand All @@ -278,19 +275,18 @@ jobs:
});

it('should extract deployment jobs predeploy', () => {
const res = extractPackageFile(
`
jobs:
- deployment: deployment_one
strategy:
runOnce:
preDeploy:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'`,
azurePipelinesFilename,
);
const packageFile = codeBlock`
jobs:
- deployment: deployment_one
strategy:
runOnce:
preDeploy:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
Expand All @@ -301,19 +297,18 @@ jobs:
});

it('should extract deployment jobs route', () => {
const res = extractPackageFile(
`
jobs:
- deployment: deployment_one
strategy:
runOnce:
routeTraffic:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'`,
azurePipelinesFilename,
);
const packageFile = codeBlock`
jobs:
- deployment: deployment_one
strategy:
runOnce:
routeTraffic:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
Expand All @@ -324,19 +319,18 @@ jobs:
});

it('should extract deployment jobs rolling', () => {
const res = extractPackageFile(
`
jobs:
- deployment: deployment_one
strategy:
rolling:
deploy:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'`,
azurePipelinesFilename,
);
const packageFile = codeBlock`
jobs:
- deployment: deployment_one
strategy:
rolling:
deploy:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
Expand All @@ -347,19 +341,18 @@ jobs:
});

it('should extract deployment jobs canary', () => {
const res = extractPackageFile(
`
jobs:
- deployment: deployment_one
strategy:
canary:
deploy:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'`,
azurePipelinesFilename,
);
const packageFile = codeBlock`
jobs:
- deployment: deployment_one
strategy:
canary:
deploy:
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
Expand All @@ -370,18 +363,17 @@ jobs:
});

it('should extract stages', () => {
const res = extractPackageFile(
`
stages:
- stage: stage_one
jobs:
- job: job_one
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'`,
azurePipelinesFilename,
);
const packageFile = codeBlock`
stages:
- stage: stage_one
jobs:
- job: job_one
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
Expand All @@ -392,16 +384,15 @@ stages:
});

it('should extract jobs', () => {
const res = extractPackageFile(
`
jobs:
- job: job_one
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'`,
azurePipelinesFilename,
);
const packageFile = codeBlock`
jobs:
- job: job_one
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
Expand All @@ -412,15 +403,13 @@ jobs:
});

it('should extract steps', () => {
const res = extractPackageFile(
`
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`,
azurePipelinesFilename,
);
const packageFile = codeBlock`
steps:
- task: Bash@3
inputs:
script: 'echo Hello World'
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res?.deps).toEqual([
{
depName: 'Bash',
Expand All @@ -431,10 +420,11 @@ steps:
});

it('should return null when task alias used', () => {
const content = `
steps:
- bash: 'echo Hello World'`;
const res = extractPackageFile(content, azurePipelinesFilename);
const packageFile = codeBlock`
steps:
- bash: 'echo Hello World';
`;
const res = extractPackageFile(packageFile, azurePipelinesFilename);
expect(res).toBeNull();
});
});
Expand Down

0 comments on commit 6987e13

Please sign in to comment.