mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
check: add unit tests to cover the new code, fix linter errors
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user