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

Parse out Merkle Roots: change `handleIndex` to `getMerkleRoots` #40

Closed xiekeyang closed 7 years ago

xiekeyang commented 7 years ago

To remove http response stuff (checking mediatype and decoding body) from index handle function to *engine.Get.

We should only keep this internal function to parse out the merkle roots.

And improve the unit test to fit the changed function. It has to remove the test cases for checking bad index json format. Because it exists no more in new function. Maybe we should check it in *engine.Get tests.

Signed-off-by: xiekeyang xiekeyang@huawei.com

xiekeyang commented 7 years ago

Maybe we should check it in *engine.Get tests.

https://github.com/xiekeyang/oci-discovery/blame/master/tools/indextemplate/indextemplate_test.go#L262-L326 just want to validate the Index structure https://github.com/xiekeyang/oci-discovery/blame/master/tools/newimagespec/newimagespec.go#L30-L33. It is not for checking any function. So I think we might use json.Decode() for test cases directly.

wking commented 7 years ago

Now that we have media-type checking, I think we want to add wrong-media-ype tests to TestHandleIndexBad too. I don't have Get tests, because Go doesn't seem to have anything as convenient as Python's unittest.mock.patch. So my plan was to split Get into helpers with everything before the network access and everything after the network access. The less untested code inGet, the better. I'll file a PR with that tonight.

xiekeyang commented 7 years ago

LGTM