vladopajic / go-test-coverage

go-test-coverage is tool and github action which reports issues when test coverage is below set threshold
GNU General Public License v3.0
80 stars 10 forks source link

Override order issue #23

Closed stuart-clark-exeter closed 1 year ago

stuart-clark-exeter commented 1 year ago

If I have my config like this:

override:
  - threshold: 90
    path: ^x/.+/keeper(/|$)
  - threshold: 80
    path: ^x/organization/keeper/identity\.go

Then x/organization/keeper/identity.go is still held to 90% coverage

There is a work around, this works as expected:

override:
  - threshold: 80
    path: ^x/organization/keeper/identity\.go
  - threshold: 90
    path: ^x/.+/keeper(/|$)

So I think either this needs to be documented, or better yet the more "precise" regex is favoured when selecting thresholds.

Thanks again for all the effort that has / is being put into this library I'm very grateful!

vladopajic commented 1 year ago

@stuart-clark-exeter thanks for letting me know.

The way override rules currently work is that first rule that matches path is applied. Because of this, override rules should be listed in order from vary specific to more general rules - like you did in provided example.

I'll make sure to mention this in the docs.