Closed xiekeyang closed 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.
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.
LGTM
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