xiekeyang / oci-discovery

Contain the OCI Ref-engine Discovery specification and related specifications as an extention to the image specification.
Other
2 stars 1 forks source link

tools/indextemplate: Refactor into getPreFetch and getPostFetch #41

Closed wking closed 7 years ago

wking commented 7 years ago

Go doesn't seem to have an analog to Python's unittest.mock.patch, so increase test coverage by moving as much as possible out of Get and into pre- and post-fetch helper methods. With this commit, we have:

$ go test -cover ./tools/indextemplate/...
ok      github.com/xiekeyang/oci-discovery/tools/indextemplate  0.004s  coverage: 74.1% of statements

while before this commit we had:

$ go test -cover ./tools/indextemplate/...
ok      github.com/xiekeyang/oci-discovery/tools/indextemplate  0.003s  coverage: 33.9% of statements

although not all of that difference is due to better Get decomposition.

xiekeyang commented 7 years ago

LGTM