frictionlessdata / tableschema-go

A Go library for working with Table Schema.
MIT License
46 stars 10 forks source link

Add Date minimum/maximum constraints #57

Closed cored closed 6 years ago

cored commented 6 years ago

for issue #44

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.1%) to 94.456% when pulling b1f459037ac56278d671b5a44275f0d8e7a8aafe on cored:add-date-min-max-constraint into 74e0168422fb163c624428a21a1913bb775b7a79 on frictionlessdata:master.

cored commented 6 years ago

@danielfireman I'm following same patterns in the codebase, however, there are some things that I don't quite understand. Why is it that the test does assertions against private functions? Wouldn't be better to use schema_test package for the tests and just test public functions?. If the reason is that these functions support a higher level component why not just add the test at that level?

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.1%) to 94.028% when pulling 1d175fb17c8a2de5327fbf477aed3167ccd7f44b on cored:add-date-min-max-constraint into f0344dc49b590983af680b315652f935ff462210 on frictionlessdata:master.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.1%) to 94.028% when pulling 1d175fb17c8a2de5327fbf477aed3167ccd7f44b on cored:add-date-min-max-constraint into f0344dc49b590983af680b315652f935ff462210 on frictionlessdata:master.

danielfireman commented 6 years ago

Hi @cored, thanks for your contributions!

About your question:

@danielfireman I'm following same patterns in the codebase, however, there are some things that I don't quite understand. Why is it that the test does assertions against private functions? Wouldn't be better to use schema_test package for the tests and just test public functions?. If the reason is that these functions support a higher level component why not just add the test at that level?

As the code gets more complex, it is usually better to rely more heavily on unit testing. There are many reasons for that, including easier maintenance, faster, simpler (more benefits here).

Let's say we decide to test that against the public Field.Decode. That simple test would involve: i) creating a field as a string, ii) call json.Unmarshal and iii) either check error or success. That still quite simple, but I its much simpler to assume the Field struct knows how to perform steps i and ii and check the third step as a unit.