Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Adding explicit test for service build variable group and variables a…
Browse files Browse the repository at this point in the history
…nd rings in build pipelines
  • Loading branch information
mtarng committed Apr 16, 2020
1 parent de8cc30 commit 069e518
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
6 changes: 3 additions & 3 deletions docs/commands/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -642,12 +642,12 @@
"defaultValue": ""
},
{
"arg": "--service-build-vg <comma-delimitated-list-of-middleware-names>",
"arg": "--service-build-vg <comma-delimitated-list-of-variable-group-names>",
"description": "List of variable groups to be linked to service pipeline. i.e. bedrock-vg,fabrikam-vg",
"defaultValue": ""
},
{
"arg": "--service-build-variables <comma-delimitated-list-of-middleware-names>",
"arg": "--service-build-variables <comma-delimitated-list-of-variable-names>",
"description": "List of variables from existing variable groups; will be used as build arguments in Docker build process. i.e. FOO,BAR",
"defaultValue": ""
}
Expand Down Expand Up @@ -744,4 +744,4 @@
}
]
}
}
}
37 changes: 36 additions & 1 deletion src/lib/fileutils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ describe("generateServiceBuildAndUpdatePipelineYaml", () => {

afterEach(() => {
mockFs.restore();
jest.clearAllMocks();
});

it("should not do anything if build-update-hld.yaml exists", () => {
Expand Down Expand Up @@ -209,7 +210,7 @@ describe("generateServiceBuildAndUpdatePipelineYaml", () => {
path.join(targetDirectory, serviceDirectory),
[],
[],
["${serviceBuildVariables}"]
[]
);

expect(writeSpy).toBeCalledWith(
Expand All @@ -231,6 +232,40 @@ describe("generateServiceBuildAndUpdatePipelineYaml", () => {
expect(writeSpy).toBeCalled();
});

it("generating a build pipeline with rings and service build variables", () => {
const absTargetPath = path.resolve(targetDirectory);
const expectedFilePath = `${absTargetPath}/${serviceDirectory}/${SERVICE_PIPELINE_FILENAME}`;

generateServiceBuildAndUpdatePipelineYaml(
targetDirectory,
["master", "stage"],
"my-service",
path.join(targetDirectory, serviceDirectory),
[],
["my-build-vg"],
["VAR1,VAR2"]
);

expect(writeSpy).toBeCalledWith(
expectedFilePath,
`${getVersionMessage()}\n`,
"utf8"
);
expect(appendSpy).toBeCalledWith(
expectedFilePath,
createTestServiceBuildAndUpdatePipelineYaml(
true,
"my-service",
"./my-service",
["master", "stage"],
["my-build-vg"],
["VAR1,VAR2"]
),
"utf8"
);
expect(writeSpy).toBeCalled();
});

test("no path trigger injected when the path is the project root (is: ./)", () => {
const serviceYaml = serviceBuildAndUpdatePipeline("my-service", "./", [
"master",
Expand Down
2 changes: 1 addition & 1 deletion src/test/mockFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const createTestServiceBuildAndUpdatePipelineYaml = (
relativeServicePathFormatted = "./my-service",
ringBranches: string[] = ["master", "qa", "test"],
variableGroups: string[] = [],
serviceBuildVariables: string[] = ["${serviceBuildVariables}"]
serviceBuildVariables: string[] = []
): AzurePipelinesYaml | string => {
const relativeServiceForDockerfile = relativeServicePathFormatted.startsWith(
"./"
Expand Down

0 comments on commit 069e518

Please sign in to comment.