-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1674 from contentstack/development
DX | 14-11-2024 | Release
- Loading branch information
Showing
99 changed files
with
6,395 additions
and
6,920 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
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
28 changes: 14 additions & 14 deletions
28
packages/contentstack-audit/test/unit/commands/index.test.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 |
---|---|---|
@@ -1,46 +1,46 @@ | ||
import winston from 'winston'; | ||
import { expect, test as fancy } from '@oclif/test'; | ||
import { expect } from 'chai'; | ||
import { runCommand } from '@oclif/test'; | ||
import fancy from 'fancy-test'; | ||
import { FileTransportInstance } from 'winston/lib/winston/transports'; | ||
|
||
import { AuditBaseCommand } from '../../../src/audit-base-command'; | ||
|
||
describe('Audit command', () => { | ||
const fsTransport = class FsTransport { | ||
filename!: string; | ||
} as FileTransportInstance; | ||
|
||
describe('Audit run method', () => { | ||
const test = fancy.loadConfig({ root: process.cwd() }); | ||
test | ||
fancy | ||
.stdout({ print: process.env.PRINT === 'true' || false }) | ||
.stub(winston.transports, 'File', () => fsTransport) | ||
.stub(winston, 'createLogger', () => ({ log: () => {}, error: () => {} })) | ||
.stub(AuditBaseCommand.prototype, 'start', () => {}) | ||
.command(['cm:stacks:audit']) | ||
.it('should trigger AuditBaseCommand start method', ({ stdout }) => { | ||
.it('should trigger AuditBaseCommand start method', async () => { | ||
const { stdout } = await runCommand(['cm:stacks:audit'], { root: process.cwd() }); | ||
expect(stdout).to.be.string; | ||
}); | ||
|
||
test | ||
fancy | ||
.stderr({ print: false }) | ||
.stdout({ print: process.env.PRINT === 'true' || false }) | ||
.stub(winston.transports, 'File', () => fsTransport) | ||
.stub(winston, 'createLogger', () => ({ log: console.log, error: console.error })) | ||
.stub(AuditBaseCommand.prototype, 'start', () => Promise.reject('process failed')) | ||
.command(['cm:stacks:audit']) | ||
.exit(1) | ||
.it('should log any error and exit with status code 1'); | ||
.it('should log any error and exit with status code 1', async () => { | ||
await runCommand(['cm:stacks:audit'], { root: process.cwd() }); | ||
}); | ||
|
||
test | ||
fancy | ||
.stderr({ print: false }) | ||
.stdout({ print: process.env.PRINT === 'true' || false }) | ||
.stub(winston.transports, 'File', () => fsTransport) | ||
.stub(winston, 'createLogger', () => ({ log: console.log, error: console.error })) | ||
.stub(AuditBaseCommand.prototype, 'start', () => { | ||
throw Error('process failed'); | ||
}) | ||
.command(['cm:stacks:audit']) | ||
.exit(1) | ||
.it('should log the error objet message and exit with status code 1'); | ||
.it('should log the error objet message and exit with status code 1', async () => { | ||
await runCommand(['cm:stacks:audit'], { root: process.cwd() }); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.