Skip to content

Commit

Permalink
fix: template is already JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
corymhall committed Oct 30, 2023
1 parent 1e1cb91 commit 5e6bde2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/assembly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,5 @@ export interface StageInfo {
export interface StackInfo {
name: string;
lookupRole?: BootstrapRole;
content: string;
content: { [key: string]: any };
}
2 changes: 1 addition & 1 deletion src/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class StackDiff {
const res = await this.client.send(cmd);
const newTemplate = res.TemplateBody ?
JSON.parse(res.TemplateBody) : {};
const diff = diffTemplate(newTemplate, JSON.parse(this.stack.content));
const diff = diffTemplate(newTemplate, this.stack.content);
const changes = this.evaluateDiff(this.stack.name, diff);
return {
diff,
Expand Down
36 changes: 18 additions & 18 deletions test/diff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ beforeEach(() => {
describe('StackDiff', () => {
const stackInfo: StackInfo = {
name: 'my-stack',
content: JSON.stringify({
content: {
Resources: {
MyRole: {
Type: 'AWS::IAM::Role',
Expand All @@ -22,12 +22,12 @@ describe('StackDiff', () => {
},
},
},
}),
},
};
test('no template diff', async () => {
cfnMock.on(GetTemplateCommand)
.resolves({
TemplateBody: stackInfo.content,
TemplateBody: JSON.stringify(stackInfo.content),
});
const stackDiff = new StackDiff(stackInfo, []);
const { diff, destructiveChanges } = await stackDiff.diffStack();
Expand All @@ -38,11 +38,11 @@ describe('StackDiff', () => {
test('diff with no destructive changes', async () => {
cfnMock.on(GetTemplateCommand)
.resolves({
TemplateBody: stackInfo.content,
TemplateBody: JSON.stringify(stackInfo.content),
});
const stackDiff = new StackDiff({
name: 'my-stack',
content: JSON.stringify({
content: {
Resources: {
MyRole: {
Type: 'AWS::IAM::Role',
Expand All @@ -52,7 +52,7 @@ describe('StackDiff', () => {
},
},
},
}),
},
}, []);
const { diff, destructiveChanges } = await stackDiff.diffStack();
expect(diff.isEmpty).toEqual(false);
Expand All @@ -64,11 +64,11 @@ describe('StackDiff', () => {
test('diff with destructive changes', async () => {
cfnMock.on(GetTemplateCommand)
.resolves({
TemplateBody: stackInfo.content,
TemplateBody: JSON.stringify(stackInfo.content),
});
const stackDiff = new StackDiff({
name: 'my-stack',
content: JSON.stringify({
content: {
Resources: {
MyRole: {
Type: 'AWS::IAM::Role',
Expand All @@ -77,7 +77,7 @@ describe('StackDiff', () => {
},
},
},
}),
},
}, []);
const { diff, destructiveChanges } = await stackDiff.diffStack();
expect(diff.isEmpty).toEqual(false);
Expand All @@ -93,11 +93,11 @@ describe('StackDiff', () => {
test('diff with allowed destructive changes', async () => {
cfnMock.on(GetTemplateCommand)
.resolves({
TemplateBody: stackInfo.content,
TemplateBody: JSON.stringify(stackInfo.content),
});
const stackDiff = new StackDiff({
name: 'my-stack',
content: JSON.stringify({
content: {
Resources: {
MyRole: {
Type: 'AWS::IAM::Role',
Expand All @@ -106,7 +106,7 @@ describe('StackDiff', () => {
},
},
},
}),
},
}, ['AWS::IAM::Role']);
const { diff, destructiveChanges } = await stackDiff.diffStack();
expect(diff.isEmpty).toEqual(false);
Expand All @@ -119,7 +119,7 @@ describe('StackDiff', () => {
describe('StageProcessor', () => {
const stackInfo: StackInfo = {
name: 'my-stack',
content: JSON.stringify({
content: {
Resources: {
MyRole: {
Type: 'AWS::IAM::Role',
Expand All @@ -128,13 +128,13 @@ describe('StageProcessor', () => {
},
},
},
}),
},
};

test('stage with no diffs', async () => {
cfnMock.on(GetTemplateCommand)
.resolves({
TemplateBody: stackInfo.content,
TemplateBody: JSON.stringify(stackInfo.content),
});
const processor = new StageProcessor([
{
Expand All @@ -153,14 +153,14 @@ describe('StageProcessor', () => {
test('stage with no diff', async () => {
cfnMock.on(GetTemplateCommand)
.resolves({
TemplateBody: stackInfo.content,
TemplateBody: JSON.stringify(stackInfo.content),
});
const processor = new StageProcessor([
{
name: 'Stage1',
stacks: [{
name: 'my-stack',
content: JSON.stringify({
content: {
Resources: {
MyRole: {
Type: 'AWS::IAM::Role',
Expand All @@ -169,7 +169,7 @@ describe('StageProcessor', () => {
},
},
},
}),
},
}],
},
], []);
Expand Down

0 comments on commit 5e6bde2

Please sign in to comment.