Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit 0a2700e

Browse files
committed
Reconcile test fixes
1 parent 067b409 commit 0a2700e

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

src/commands/hld/reconcile.test.ts

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ describe("reconcile tests", () => {
312312
exec: jest.fn().mockReturnValue(Promise.resolve({})),
313313
generateAccessYaml: jest.fn(),
314314
getGitOrigin: jest.fn(),
315-
test: jest.fn().mockReturnValue(false),
316315
writeFile: jest.fn()
317316
};
318317

@@ -418,7 +417,32 @@ describe("reconcile tests", () => {
418417
expect(dependencies.createIngressRouteForRing).not.toHaveBeenCalled();
419418
});
420419

421-
it("will re-write rings, even if they exist", async () => {
420+
it("overwrites existing rings", async () => {
421+
bedrockYaml.rings = {
422+
dev: {
423+
isDefault: true
424+
}
425+
};
426+
427+
for (const i of Array(2)) {
428+
await reconcileHld(
429+
dependencies,
430+
bedrockYaml,
431+
"service",
432+
"./path/to/hld",
433+
"./path/to/app"
434+
);
435+
}
436+
437+
// Reconcile should run twice against the existing service's rings.
438+
expect(dependencies.createRingComponent).toHaveBeenCalledTimes(2);
439+
expect(dependencies.addChartToRing).toHaveBeenCalledTimes(2);
440+
expect(dependencies.createStaticComponent).toHaveBeenCalledTimes(2);
441+
expect(dependencies.createMiddlewareForRing).toHaveBeenCalledTimes(2);
442+
expect(dependencies.createIngressRouteForRing).toHaveBeenCalledTimes(2);
443+
});
444+
445+
it("does not create rings, if they don't exist wihin bedrock.yaml", async () => {
422446
bedrockYaml.rings = {};
423447

424448
await reconcileHld(
@@ -429,10 +453,10 @@ describe("reconcile tests", () => {
429453
"./path/to/app"
430454
);
431455

432-
expect(dependencies.createRingComponent).toHaveBeenCalled();
433-
expect(dependencies.createStaticComponent).toHaveBeenCalled();
434-
expect(dependencies.createMiddlewareForRing).toHaveBeenCalled();
435-
expect(dependencies.createIngressRouteForRing).toHaveBeenCalled();
456+
expect(dependencies.createRingComponent).not.toHaveBeenCalled();
457+
expect(dependencies.createStaticComponent).not.toHaveBeenCalled();
458+
expect(dependencies.createMiddlewareForRing).not.toHaveBeenCalled();
459+
expect(dependencies.createIngressRouteForRing).not.toHaveBeenCalled();
436460
});
437461

438462
it("does not create service components if the service path is `.`, and a display name does not exist", async () => {

src/commands/hld/reconcile.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ export interface IReconcileDependencies {
6363

6464
writeFile: (path: string, contents: string) => void;
6565

66-
test: (option: shelljs.TestOptions, path: string) => boolean;
67-
6866
getGitOrigin: (path?: string) => Promise<string>;
6967

7068
generateAccessYaml: (
@@ -170,7 +168,6 @@ export const execute = async (
170168
exec: execAndLog,
171169
generateAccessYaml,
172170
getGitOrigin: tryGetGitOrigin,
173-
test: shelljs.test,
174171
writeFile: writeFileSync
175172
};
176173

0 commit comments

Comments
 (0)