-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update development disable command to pull service by default (#110)
* Currently when service is disabled in development mode if a user does not delete it or pull it manually, the image will remain to be the image built by development mode potentially. * Pulling the image after disabling will mean that the service is reloaded as the one held in ECR * Added the `-P` to the disable command to maintain current behaviour if desired * Reorganied `disable.spec.ts` mocks to use automatic mocks and not manual mock * Add a method which can be overidden in children of AbstractStateModificationCommand so that actions can occur after the hook has successfully run
- Loading branch information
1 parent
cbbb91b
commit 7e9e598
Showing
8 changed files
with
242 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { AbstractLogHandler, Logger, LogHandler } from "./logs-handler.js"; | ||
|
||
export class LogNothingLogHandler extends AbstractLogHandler { | ||
protected logToConsole (_: string[]): void { } | ||
|
||
} | ||
|
||
export default LogNothingLogHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { expect, jest } from "@jest/globals"; | ||
import fs from "fs"; | ||
import LogNothingLogHandler from "../../../src/run/logs/LogNothingLogHandler"; | ||
|
||
describe("LogNothingLogHandler", () => { | ||
|
||
const writeFileSyncSpy = jest.spyOn(fs, "writeFileSync"); | ||
const logFile = "/home/user/project/something.log"; | ||
|
||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
|
||
writeFileSyncSpy.mockImplementation((_, __) => {}); | ||
}); | ||
|
||
it("does not log any lines", () => { | ||
const loggerMock = { | ||
log: jest.fn() | ||
}; | ||
|
||
const logNothingLogHandler = new LogNothingLogHandler(logFile, loggerMock); | ||
|
||
logNothingLogHandler.handle("one\ntwo\n\tthree\n"); | ||
|
||
expect(loggerMock.log).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it("does write log entries to file", () => { | ||
const logLines = [ | ||
"Watch configuration for service \"overseas-application\"", | ||
"- Action rebuild for path \"/do\"", | ||
"another log entry" | ||
]; | ||
const logMessage = logLines.join("\n"); | ||
const loggerMock = { | ||
log: jest.fn() | ||
}; | ||
|
||
const logNothingLogHandler = new LogNothingLogHandler(logFile, loggerMock); | ||
|
||
logNothingLogHandler.handle(logMessage); | ||
|
||
expect(writeFileSyncSpy).toHaveBeenCalledTimes(1); | ||
|
||
const call = writeFileSyncSpy.mock.calls[0]; | ||
|
||
expect(call[0]).toBe(logFile); | ||
expect(call[2]).toEqual({ | ||
flag: "a" | ||
}); | ||
|
||
const contentsWrittenToFile = call[1]; | ||
|
||
for (const expectedLine of logLines) { | ||
// eslint-disable-next-line no-useless-escape | ||
const pattern = new RegExp(`\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\.\\d{3}Z\\s-\\s${expectedLine}`, "g"); | ||
|
||
expect(pattern.test(contentsWrittenToFile.toString())).toBe(true); | ||
} | ||
}); | ||
|
||
}); |