Skip to content

Commit 8ae2687

Browse files
committed
[ISSUE#51]: file renamed
igned-off-by: ashish <ashishpatel0720@gmail.com> Signed-off-by: ashish <ashishpatel0720@gmail.com>
1 parent ee76424 commit 8ae2687

File tree

7 files changed

+36053
-144036
lines changed

7 files changed

+36053
-144036
lines changed

src/commands/avro.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,15 @@ export default class Avro extends Command {
6969
Logger.success(this, `output written to file: ${chalk.green(flags.output)}`) // this will output error and exit command
7070
}
7171
private toAvro(flags: any, args: any) {
72-
72+
if (!flags.schema)
73+
Logger.error(this, 'Schema file is not provided')
74+
this.checkValidSchema(flags, args)
7375
}
7476

75-
// private checkValidAvsc(){
76-
// // Or we can specify a path to a schema file (not in the browser):
77-
// var type = avro.parse('./Person.avsc');
78-
// var person = {name: 'Bob', address: {city: 'Cambridge', zip: '02139'}};
79-
// var status = type.isValid(person); // Boolean status.
80-
// }
77+
private checkValidSchema(flags: any, args: any) {
78+
let avroFile = avro.parse(flags.file)
79+
// var schemaFile = {name: 'Bob', address: {city: 'Cambridge', zip: '02139'}}
80+
// var status = type.isValid(person); // Boolean status.
81+
console.log(avroFile)
82+
}
8183
}

test/commands/avro.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ describe('avro', () => {
1313
})
1414
test
1515
.stdout()
16-
.command(['avro', '-f' ,'test/resources/avro/test-tabular.avro'])
16+
.command(['avro', '-f' ,'test/resources/avro/person.avro'])
1717
.exit(0)
1818
.it('if output is not passed', ctx => {
1919
expect(ctx.stdout).to.contain('Output file is not provided')
2020
})
2121

2222
test
2323
.stdout()
24-
.command(['avro', '-f' ,'test/resources/avro/test-tabular.avro', '-o', 'output_file.example'])
24+
.command(['avro', '-f' ,'test/resources/avro/person.avro', '-o', 'output_file.example'])
2525
.exit(0)
2626
.it('if command not passed', ctx => {
2727
expect(ctx.stdout).to.contain('Command is empty or not provided')
2828
})
2929

3030
test
3131
.stdout()
32-
.command(['avro', '-f' ,'test/resources/avro/test-tabular.avro', '-o', 'output_file.example', 'unsupported_command'])
32+
.command(['avro', '-f' ,'test/resources/avro/person.avro', '-o', 'output_file.example', 'unsupported_command'])
3333
.exit(0)
3434
.it('if command is invalid', ctx => {
3535
expect(ctx.stdout).to.contain('Unsupported Command')
@@ -42,4 +42,12 @@ describe('avro', () => {
4242
.it('if input file path is invalid', ctx => {
4343
expect(ctx.stdout).to.contain('Unsupported Command')
4444
})
45+
46+
test
47+
.stdout()
48+
.command(['avro', '-f' ,'test/resources/avro/.avro', '-t' ,'test/resources/avro/schema.avsc', '-o', 'output_file.example', 'get_schema'])
49+
.exit(0)
50+
.it('if schema file path is not passed', ctx => {
51+
expect(ctx.stdout).to.contain('Unsupported Command')
52+
})
4553
})

0 commit comments

Comments
 (0)