-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add flag to support delete changes (#258)
- Loading branch information
Showing
11 changed files
with
520 additions
and
79 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
9 changes: 9 additions & 0 deletions
9
packages/cli/src/lib/snapshot/reportViewer/reportViewerDataModels.ts
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,9 @@ | ||
import {ResourceSnapshotsReportOperationModel} from '@coveord/platform-client'; | ||
|
||
export type ReportViewerOperationName = | ||
keyof ResourceSnapshotsReportOperationModel; | ||
|
||
export interface ReportViewerResourceReportModel { | ||
name: string; | ||
operations: ResourceSnapshotsReportOperationModel; | ||
} |
90 changes: 90 additions & 0 deletions
90
packages/cli/src/lib/snapshot/reportViewer/reportViewerSection.spec.ts
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,90 @@ | ||
import stripAnsi from 'strip-ansi'; | ||
import dedent from 'ts-dedent'; | ||
import { | ||
ReportViewerOperationName, | ||
ReportViewerResourceReportModel, | ||
} from './reportViewerDataModels'; | ||
import {ReportViewerSection} from './reportViewerSection'; | ||
|
||
describe('ReportViewerSection', () => { | ||
const resourceWithChanges: ReportViewerResourceReportModel = { | ||
name: 'FOO_RESOURCE', | ||
operations: { | ||
resourcesCreated: 10, | ||
resourcesDeleted: 2, | ||
resourcesInError: 4, | ||
resourcesRecreated: 0, | ||
resourcesUnchanged: 5, | ||
resourcesUpdated: 0, | ||
}, | ||
}; | ||
|
||
const unsyncedResource: ReportViewerResourceReportModel = { | ||
name: 'UNSYNCED_RESOURCE', | ||
operations: { | ||
resourcesCreated: 0, | ||
resourcesDeleted: 0, | ||
resourcesInError: 0, | ||
resourcesRecreated: 0, | ||
resourcesUnchanged: 0, | ||
resourcesUpdated: 0, | ||
}, | ||
}; | ||
|
||
const allOperationsAllowed: ReportViewerOperationName[] = [ | ||
'resourcesCreated', | ||
'resourcesDeleted', | ||
'resourcesInError', | ||
'resourcesRecreated', | ||
'resourcesUnchanged', | ||
'resourcesUpdated', | ||
]; | ||
|
||
describe('when there are no resource changes', () => { | ||
it('should print nothing', () => { | ||
const section = new ReportViewerSection( | ||
unsyncedResource, | ||
allOperationsAllowed | ||
); | ||
|
||
expect(section.display(0)).toEqual(''); | ||
}); | ||
}); | ||
|
||
describe('when there are resource changes', () => { | ||
const section = new ReportViewerSection( | ||
resourceWithChanges, | ||
allOperationsAllowed | ||
); | ||
|
||
it('should print all operations with changes', () => { | ||
expect(stripAnsi(section.display(0))).toContain(dedent` | ||
+10 to create | ||
-2 to delete | ||
!4 in error | ||
5 unchanged | ||
`); | ||
}); | ||
|
||
it('should indent with right amount of spaces', () => { | ||
expect(stripAnsi(section.display(3))).toContain(dedent` | ||
+ 10 to create | ||
- 2 to delete | ||
! 4 in error | ||
5 unchanged | ||
`); | ||
}); | ||
}); | ||
|
||
describe('when only a subset of operations are allowed ', () => { | ||
const section = new ReportViewerSection(resourceWithChanges, [ | ||
'resourcesDeleted', | ||
]); | ||
|
||
it('should print allowed operation', () => { | ||
expect(stripAnsi(section.display(0))).toContain(dedent` | ||
-2 to delete | ||
`); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.