|
1 | 1 | import { Logger } from "@octopusdeploy/api-client";
|
2 | 2 | import { createCommandFromInputs } from "./inputCommandBuilder";
|
3 | 3 | import { MockTaskWrapper } from "../../Utils/MockTaskWrapper";
|
| 4 | +import * as path from "path"; |
| 5 | +import fs from "fs"; |
| 6 | +import os from "os"; |
4 | 7 |
|
5 | 8 | describe("getInputCommand", () => {
|
6 | 9 | let logger: Logger;
|
@@ -43,6 +46,32 @@ describe("getInputCommand", () => {
|
43 | 46 | expect(command.Packages).toStrictEqual(["Baz:2.5.0", "Step1:Foo:1.0.0", "Bar:2.0.0"]);
|
44 | 47 | });
|
45 | 48 |
|
| 49 | + test("release notes file", async () => { |
| 50 | + const tempOutDir = await fs.mkdtempSync(path.join(os.tmpdir(), "octopus_")); |
| 51 | + const notesPath = path.join(tempOutDir, "notes.txt"); |
| 52 | + |
| 53 | + task.addVariableString("Space", "Default"); |
| 54 | + task.addVariableString("Project", "Awesome project"); |
| 55 | + task.addVariableString("ReleaseNotesFile", notesPath); |
| 56 | + |
| 57 | + fs.writeFileSync(notesPath, "this is a release note"); |
| 58 | + const command = createCommandFromInputs(logger, task); |
| 59 | + expect(command.ReleaseNotes).toBe("this is a release note"); |
| 60 | + }); |
| 61 | + |
| 62 | + test("specifying both release notes and release notes file causes error", async () => { |
| 63 | + const tempOutDir = await fs.mkdtempSync(path.join(os.tmpdir(), "octopus_")); |
| 64 | + const notesPath = path.join(tempOutDir, "notes.txt"); |
| 65 | + |
| 66 | + task.addVariableString("Space", "Default"); |
| 67 | + task.addVariableString("Project", "Awesome project"); |
| 68 | + task.addVariableString("ReleaseNotes", "inline release notes"); |
| 69 | + task.addVariableString("ReleaseNotesFile", notesPath); |
| 70 | + |
| 71 | + fs.writeFileSync(notesPath, "this is a release note"); |
| 72 | + expect(() => createCommandFromInputs(logger, task)).toThrowError("cannot specify ReleaseNotes and ReleaseNotesFile"); |
| 73 | + }); |
| 74 | + |
46 | 75 | test("duplicate variable name, variables field takes precedence", () => {
|
47 | 76 | task.addVariableString("Space", "Default");
|
48 | 77 | task.addVariableString("Project", "Awesome project");
|
|
0 commit comments