Skip to content

Commit 09a2068

Browse files
authored
Merge pull request #4 from time-loop/Morgan-Szafranski/add-basic-tests
2 parents 0e6b238 + e3e13a8 commit 09a2068

File tree

4 files changed

+78
-3
lines changed

4 files changed

+78
-3
lines changed

src/parsingLogic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function rebuildDiffsIntoCdkLog(stacks: string[]) {
5555

5656
function separateDiffLogIntoStacks(log: string) {
5757
const stacks = log.split(new RegExp('(^Stack )', 'gm'));
58-
if (stacks[0] === '') stacks.shift();
58+
if (stacks[0] === '' || !stacks[0].startsWith('Stack')) stacks.shift();
5959
return stacks.map((_, i) => (i % 2 === 0 ? '' : stacks[i - 1] + stacks[i])).filter((e) => e);
6060
}
6161

test/__snapshots__/cdkLogParser.test.ts.snap

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/cdkLogParser.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { getParsedStacks, loadCdkDiffLog } from '../src/parsingLogic';
22

3-
test('no-op', () => {});
4-
53
describe('getParsedStacks', () => {
64
test('should remove all non-sense changes from a service instance diff log', () => {
75
const cdkDiffLogContent = loadCdkDiffLog('test/data/serviceInstanceOutput.txt');
@@ -14,4 +12,10 @@ describe('getParsedStacks', () => {
1412
const parsedStacks = getParsedStacks(cdkDiffLogContent);
1513
expect(parsedStacks).toMatchSnapshot();
1614
});
15+
16+
test('should ignore content before the first stack diff and NOT clobber the stack names', () => {
17+
const cdkDiffLogContent = loadCdkDiffLog('test/data/dontClobberStackName.txt');
18+
const parsedStacks = getParsedStacks(cdkDiffLogContent);
19+
expect(parsedStacks).toMatchSnapshot();
20+
});
1721
});

0 commit comments

Comments
 (0)