-
Notifications
You must be signed in to change notification settings - Fork 3
109 make configs into case classes #110
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,21 +14,35 @@ | |||||||||||||
| * limitations under the License. | ||||||||||||||
| */ | ||||||||||||||
|
|
||||||||||||||
| package za.co.absa.hermes.datasetComparison.config | ||||||||||||||
| package za.co.absa.hermes.datasetComparison | ||||||||||||||
|
|
||||||||||||||
| import org.scalatest.FunSuite | ||||||||||||||
|
|
||||||||||||||
| class TypeSafeConfigSuite extends FunSuite { | ||||||||||||||
| class DatasetComparisonConfigSuite extends FunSuite { | ||||||||||||||
| test("Manual Config Correct") { | ||||||||||||||
| val conf = DatasetComparisonConfig("errCol", "_actual", "_expected", false) | ||||||||||||||
| assert(conf.validate().isSuccess) | ||||||||||||||
| assert("errCol" == conf.errorColumnName) | ||||||||||||||
| assert("_actual" == conf.actualPrefix) | ||||||||||||||
| assert("_expected" == conf.expectedPrefix) | ||||||||||||||
| assert(!conf.allowDuplicates) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| test("Manual Config Bad Column Name") { | ||||||||||||||
| val conf = DatasetComparisonConfig("errCol", "_actua l", "_expected", false) | ||||||||||||||
| assert(conf.validate().isFailure) | ||||||||||||||
|
Comment on lines
+32
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps the checking that validation failure occurs as expected could be done for all the fields assert(DatasetComparisonConfig("errCol", "_actua l", "_expected", false).validate().isFailure)
assert(DatasetComparisonConfig("er{r}Col", "_actual", "_expected", false).validate().isFailure)
assert(DatasetComparisonConfig("errCol", "_actual", "_expe=cted", false).validate().isFailure) |
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| test("Default Config Loaded") { | ||||||||||||||
| val conf = new TypesafeConfig(None) | ||||||||||||||
| val conf = DatasetComparisonConfig.default | ||||||||||||||
| assert("errCol" == conf.errorColumnName) | ||||||||||||||
| assert("actual" == conf.actualPrefix) | ||||||||||||||
| assert("expected" == conf.expectedPrefix) | ||||||||||||||
|
Comment on lines
38
to
40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know we have discussed this already before, but I still find this suboptimal. Sorry.
Suggested change
diverging from the conventional order results in incorrect scala-test based messages. E.g.: assert("expectedValue" == "actualValue")will generate output: This results in incorrect error messages and possible confusion of the reader. (this issue appears elsewhere in the code, too)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's okay, I will switch it. It is just hard to kick the habit 👍 |
||||||||||||||
| assert(!conf.allowDuplicates) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| test("Config with provided path loaded") { | ||||||||||||||
| val conf = new TypesafeConfig(Some("confData/application.conf")) | ||||||||||||||
| val conf = DatasetComparisonConfig.fromTypeSafeConfig(Some("confData/application.conf")) | ||||||||||||||
|
|
||||||||||||||
| assert("errCol2" == conf.errorColumnName) | ||||||||||||||
| assert("actual2" == conf.actualPrefix) | ||||||||||||||
|
|
||||||||||||||
This file was deleted.
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.
Checking values of fields directly set to a case class is not wrong per se, but unnecessary in my opinion.
The validation checking makes sense.