Skip to content

Commit ff2f673

Browse files
committed
[AVRO] - All tests working
Signed-off-by: ashish <[email protected]>
1 parent 16ad96f commit ff2f673

File tree

9 files changed

+24
-9
lines changed

9 files changed

+24
-9
lines changed

β€Žsrc/commands/avro.tsβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export default class Avro extends Command {
8989
// @ts-ignore
9090
Utilities.appendStringToFile(this, flags.output, JSON.stringify(recordStr))
9191
})
92-
Logger.success(this, `output written to file: ${chalk.green(flags.output)}`) // this will output error and exit command
92+
Logger.success(this, `${chalk.blue('Json')} written to file: ${chalk.green(flags.output)}`) // this will output error and exit command
9393
}
9494

9595
private toAvro(flags: any, args: any) {
@@ -117,6 +117,7 @@ export default class Avro extends Command {
117117
Logger.warn(this, `${chalk.yellow('[SKIPPING RECORD]')} schema is invalid: ${chalk.yellowBright(JSON.stringify(data))}`)
118118
}
119119
})
120+
Logger.success(this, `${chalk.blue('Avro')} written to file: ${chalk.green(flags.output)}`) // this will output error and exit command
120121
avroEncoder.end()
121122
}
122123
}

β€Žtest/commands/avro.test.tsβ€Ž

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ describe('avro', () => {
1919
})
2020
test
2121
.stdout()
22-
.command(['avro', '-f', 'test/resources/avro/person.avro', '-o', 'output_file.example'])
22+
.command(['avro', '-f', 'test/resources/avro/person.avro', '-o', 'test/resources/avro/output/person.json'])
2323
.exit(0)
2424
.it('if command not passed', ctx => {
2525
expect(ctx.stdout).to.contain('Command is empty or not provided')
2626
})
2727
test
2828
.stdout()
29-
.command(['avro', '-f', 'test/resources/avro/person.avro', '-o', 'output_file.example', 'unsupported_command'])
29+
.command(['avro', '-f', 'test/resources/avro/person.avro', '-o', 'test/resources/avro/output/person.json', 'unsupported_command'])
3030
.exit(0)
3131
.it('if command is invalid', ctx => {
3232
expect(ctx.stdout).to.contain('Unsupported Command')
@@ -43,17 +43,12 @@ describe('avro', () => {
4343

4444
test
4545
.stdout()
46-
.command(['avro', '-f', 'test/resources/avro/person.avro', '-o', 'output_file.example', 'to_avro'])
46+
.command(['avro', '-f', 'test/resources/avro/person.json', '-o', 'test/resources/avro/output/person.avro', 'to_avro'])
4747
.exit(0)
4848
.it('if schema file path is not passed for to_avro', ctx => {
4949
expect(ctx.stdout).to.contain('Schema file is not provided')
5050
})
5151

52-
// positive cases
53-
// 1 - get schema
54-
// 2 - to json
55-
// 3 - to avro
56-
5752
/* TODO: why this tests is breaking */
5853
// test
5954
// .stdout()
@@ -62,5 +57,22 @@ describe('avro', () => {
6257
// expect(ctx.stdout).to.contain('success')
6358
// })
6459

60+
// setTimeout(() => // TODO: can we remove it and check if we can resolve promise here
61+
// expect(ctx.stdout).to.contain(' [[email protected]] minified:6.5 kB gzip:2.6 kB')
62+
// , 5000) // proving 5 seconds just to be safe
63+
64+
test
65+
.stdout()
66+
.command(['avro', '-f', 'test/resources/avro/person.avro', '-o', 'test/resources/avro/output/person.json','to_json'])
67+
.it('if to_json commands run with success', ctx => {
68+
expect(ctx.stdout).to.contain('success')
69+
})
6570

71+
test
72+
.timeout(20000) // added timeout to resolve timeout problem
73+
.stdout()
74+
.command(['avro', '-f', 'test/resources/avro/person.json', '-o', 'test/resources/avro/output/person.avro', '-t', 'test/resources/avro/person.avsc', 'to_avro'])
75+
.it('if to_avro commands run with success', ctx => {
76+
expect(ctx.stdout).to.contain('success')
77+
})
6678
})
File renamed without changes.
File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"Person","type":"record","fields":[{"name":"ID","type":"long"},{"name":"First","type":"string"},{"name":"Last","type":"string"},{"name":"Phone","type":"string"},{"name":"Age","type":"int"}]}
File renamed without changes.
158 KB
Binary file not shown.
File renamed without changes.

β€Žtest/resources/avro/person.jsonβ€Ž

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
Β (0)