Skip to content

Commit 229d610

Browse files
committed
[ISSUE#51]: two tests added
igned-off-by: ashish <ashishpatel0720@gmail.com> Signed-off-by: ashish <ashishpatel0720@gmail.com>
1 parent 6df1576 commit 229d610

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

src/commands/avro.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {Command, flags} from '@oclif/command'
2+
import * as avsc from 'avsc'
23
import * as CryptoJS from 'crypto-js'
34

45
import Logger from '../utilities/logger'
@@ -21,30 +22,28 @@ export default class Avro extends Command {
2122

2223
args.string = Utilities.getInputString(this, flags, args) // from either -s,-f or args
2324
this.checkParameters(flags, args)
25+
args.commandFunction = this.getCommandCaller(args)
2426
}
2527

2628
// to check required parameters passed or not
2729
private checkParameters(flags: any, args: any) {
28-
2930
if (args.string === undefined || args.string === '')
3031
Logger.error(this, 'Input is empty or not provided')
31-
3232
if (args.command === undefined || args.command === '')
33-
Logger.error(this, 'Input is empty or not provided')
34-
33+
Logger.error(this, 'command is empty or not provided')
3534
}
3635

3736
private getCommandCaller(args: any) {
3837
let supportedCommands = ['get_schema', 'to_json', 'to_avro']
3938

40-
let s = args.command.toUpperCase()
41-
if (s === supportedCommands[0]) {
42-
return CryptoJS.mode.CBC
43-
} else if (s === supportedCommands[1]) {
44-
return CryptoJS.mode.CFB
45-
} else if (s === supportedCommands[2]) {
46-
return CryptoJS.mode.OFB
47-
} else {
39+
switch (args.command.toLowerCase()) {
40+
case supportedCommands[0]:
41+
return 'supported'
42+
case supportedCommands[1]:
43+
return 'supported'
44+
case supportedCommands[2]:
45+
return 'supported'
46+
default:
4847
Logger.error(this, 'Unsupported Commands Mode, supported: ' + supportedCommands)
4948
}
5049
}

test/commands/avro.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ describe('avro', () => {
1616
.command(['avro', '-f' ,'test/resources/avro/test-tabular.avro'])
1717
.exit(0)
1818
.it('if command not passed', ctx => {
19-
expect(ctx.stdout).to.contain('Input is empty or not provided')
19+
expect(ctx.stdout).to.contain('command is empty or not provided')
2020
})
2121
})

0 commit comments

Comments
 (0)