check: add unit tests to cover the new code, fix linter errors

This commit is contained in:
Ramkumar Chinchani
2020-01-30 23:59:36 -08:00
parent f9a1a0fe48
commit 58040f4562
5 changed files with 157 additions and 45 deletions
+1
View File
@@ -727,6 +727,7 @@ func (is *ImageStore) FullBlobUpload(repo string, body io.Reader, digest string)
digester := sha256.New()
mw := io.MultiWriter(f, digester)
n, err := io.Copy(mw, body)
if err != nil {
return "", -1, err
}
+10
View File
@@ -58,6 +58,16 @@ func TestAPIs(t *testing.T) {
So(v, ShouldBeEmpty)
})
Convey("Full blob upload", func() {
body := []byte("this is a blob")
buf := bytes.NewBuffer(body)
d := godigest.FromBytes(body)
u, n, err := il.FullBlobUpload("test", buf, d.String())
So(err, ShouldBeNil)
So(n, ShouldEqual, len(body))
So(u, ShouldNotBeEmpty)
})
Convey("New blob upload", func() {
v, err := il.NewBlobUpload("test")
So(err, ShouldBeNil)