Skip to content
This repository has been archived by the owner on Oct 14, 2021. It is now read-only.

Commit

Permalink
Remove test case copy/move to an existing file (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
JinnyYi authored Jul 1, 2021
1 parent 17648ab commit 3339bf2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 114 deletions.
53 changes: 0 additions & 53 deletions copier.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,58 +70,5 @@ func TestCopier(t *testing.T, store types.Storager) {
})
})
})

Convey("When Copy to an existing file", func() {
c, _ := store.(types.Copier)

srcSize := rand.Int63n(4 * 1024 * 1024) // Max file size is 4MB
content, _ := ioutil.ReadAll(io.LimitReader(randbytes.NewRand(), srcSize))
src := uuid.New().String()

_, err := store.Write(src, bytes.NewReader(content), srcSize)
if err != nil {
t.Fatal(err)
}

dstSize := rand.Int63n(4 * 1024 * 1024) // Max file size is 4MB
r := io.LimitReader(randbytes.NewRand(), dstSize)
dst := uuid.New().String()

_, err = store.Write(dst, r, dstSize)
if err != nil {
t.Fatal(err)
}

defer func() {
err = store.Delete(src)
if err != nil {
t.Error(err)
}
err = store.Delete(dst)
if err != nil {
t.Error(err)
}
}()

err = c.Copy(src, dst)
Convey("The error should be nil", func() {
So(err, ShouldBeNil)
})

Convey("Read should get dst object data without error", func() {
var buf bytes.Buffer
n, err := store.Read(dst, &buf)

Convey("The error should be nil", func() {
So(err, ShouldBeNil)
})

Convey("The content should be match", func() {
So(buf, ShouldNotBeNil)
So(n, ShouldEqual, srcSize)
So(md5.Sum(buf.Bytes()), ShouldResemble, md5.Sum(content))
})
})
})
})
}
61 changes: 0 additions & 61 deletions mover.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,66 +80,5 @@ func TestMover(t *testing.T, store types.Storager) {
})
})
})

Convey("When Move to an existing file", func() {
m, _ := store.(types.Mover)

srcSize := rand.Int63n(4 * 1024 * 1024) // Max file size is 4MB
content, _ := ioutil.ReadAll(io.LimitReader(randbytes.NewRand(), srcSize))
src := uuid.New().String()

_, err := store.Write(src, bytes.NewReader(content), srcSize)
if err != nil {
t.Fatal(err)
}

dstSize := rand.Int63n(4 * 1024 * 1024) // Max file size is 4MB
r := io.LimitReader(randbytes.NewRand(), dstSize)
dst := uuid.New().String()

_, err = store.Write(dst, r, dstSize)
if err != nil {
t.Fatal(err)
}

defer func() {
err = store.Delete(src)
if err != nil {
t.Error(err)
}
err = store.Delete(dst)
if err != nil {
t.Error(err)
}
}()

err = m.Move(src, dst)
Convey("The error should be nil", func() {
So(err, ShouldBeNil)
})

Convey("Stat should get src object not exist", func() {
_, err := store.Stat(src)

Convey("The error should be ErrObjectNotExist", func() {
So(errors.Is(err, services.ErrObjectNotExist), ShouldBeTrue)
})
})

Convey("Read should get dst object data without error", func() {
var buf bytes.Buffer
n, err := store.Read(dst, &buf)

Convey("The error should be nil", func() {
So(err, ShouldBeNil)
})

Convey("The content should be match", func() {
So(buf, ShouldNotBeNil)
So(n, ShouldEqual, srcSize)
So(md5.Sum(buf.Bytes()), ShouldResemble, md5.Sum(content))
})
})
})
})
}

0 comments on commit 3339bf2

Please sign in to comment.