-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added test coverage for CSVToAvro util #50
Conversation
ajayborra
commented
Aug 13, 2018
- Added test coverage for CSVToAvro util
- Added tests to RichGenericRecord.scala
@@ -0,0 +1,47 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have too many of the same or slighly different schema and data files already.
- Can we not reuse tthe existing ones in this test?
- If not, them them give them a better names than simply adding 2.
- Perhaps move these new “bad schema” files to utils/test/resources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 1:Re: To improve coverage, had to modify the data to cover negative cases. (Limited the data copies to 5 rows)
- 2:Re: Done, Renamed files, Check them out.
- 3:Re: Done, Moved the files to the resource folder.
|
||
it should "convert GenericRecord to RichGenericRecord" in { | ||
val res = RichGenericRecord(firstRow) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to explicitly convert it - its an implicit class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more of a coverage test, will remove it.
val avroSchema: String = loadFile(avroSchemaPath) | ||
val csvFile: String = s"$testDataDir/PassengerDataAllV2.csv" | ||
val csvReader: CSVInOut = new CSVInOut(CSVOptions(header = true)) | ||
val csvRDD: RDD[Seq[String]] = csvReader.readRDD(csvFile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make csvRDD and csvFileRecordCount lazy vals
|
||
Spec(CSVToAvro.getClass) should "convert RDD[Seq[String]] to RDD[GenericRecord]" in { | ||
val res = CSVToAvro.toAvro(csvRDD, avroSchema) | ||
assert(res.isInstanceOf[RDD[GenericRecord]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
res should be a[RDD[_]]
|
||
it should "convert RDD[Seq[String]] to RDD[T]" in { | ||
val res = CSVToAvro.toAvroTyped[Passenger](csvRDD, avroSchema) | ||
assert(res.isInstanceOf[RDD[Passenger]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
Codecov Report
@@ Coverage Diff @@
## master #50 +/- ##
=========================================
+ Coverage 84.46% 84.77% +0.3%
=========================================
Files 298 298
Lines 9751 9752 +1
Branches 355 560 +205
=========================================
+ Hits 8236 8267 +31
+ Misses 1515 1485 -30
Continue to review full report at Codecov.
|
/** | ||
* Returns the resource directory path | ||
*/ | ||
protected def resourceDir = _resourceDir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to create a private val _resourceDir = "src/test/resources"
simply do:
protected def resourceDir: String ="src/test/resources"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! one minor comment