Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit d5da927

Browse files
test small file too
1 parent 8f7804f commit d5da927

File tree

2 files changed

+71
-68
lines changed

2 files changed

+71
-68
lines changed

tests/integration/integration_test.go

Lines changed: 70 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -538,74 +538,76 @@ var _ = ginkgo.Describe("Tx Types", func() {
538538
expectBlkAccept(instances[0])
539539
})
540540

541-
var path string
542-
var originalFile *os.File
543-
var err error
544-
ginkgo.By("upload file", func() {
545-
originalFile, err = os.Open("computer.gif")
546-
gomega.Ω(err).Should(gomega.BeNil())
547-
548-
c := make(chan struct{})
549-
d := make(chan struct{})
550-
go func() {
551-
asyncBlockPush(instances[0], c)
552-
close(d)
553-
}()
554-
path, err = tree.Upload(context.Background(), instances[0].cli, priv, space, originalFile, 64*units.KiB)
555-
gomega.Ω(err).Should(gomega.BeNil())
556-
close(c)
557-
<-d
558-
})
559-
560-
var newFile *os.File
561-
ginkgo.By("download file", func() {
562-
newFile, err = ioutil.TempFile("", "computer")
563-
gomega.Ω(err).Should(gomega.BeNil())
564-
565-
err = tree.Download(instances[0].cli, path, newFile)
566-
gomega.Ω(err).Should(gomega.BeNil())
567-
})
568-
569-
ginkgo.By("compare file contents", func() {
570-
_, err = originalFile.Seek(0, io.SeekStart)
571-
gomega.Ω(err).Should(gomega.BeNil())
572-
rho := sha256.New()
573-
_, err = io.Copy(rho, originalFile)
574-
gomega.Ω(err).Should(gomega.BeNil())
575-
ho := fmt.Sprintf("%x", rho.Sum(nil))
576-
577-
_, err = newFile.Seek(0, io.SeekStart)
578-
gomega.Ω(err).Should(gomega.BeNil())
579-
rhn := sha256.New()
580-
_, err = io.Copy(rhn, newFile)
581-
gomega.Ω(err).Should(gomega.BeNil())
582-
hn := fmt.Sprintf("%x", rhn.Sum(nil))
583-
584-
gomega.Ω(ho).Should(gomega.Equal(hn))
585-
586-
originalFile.Close()
587-
newFile.Close()
588-
})
589-
590-
ginkgo.By("delete file", func() {
591-
c := make(chan struct{})
592-
d := make(chan struct{})
593-
go func() {
594-
asyncBlockPush(instances[0], c)
595-
close(d)
596-
}()
597-
err = tree.Delete(context.Background(), instances[0].cli, path, priv)
598-
gomega.Ω(err).Should(gomega.BeNil())
599-
close(c)
600-
<-d
601-
602-
// Should error
603-
dummyFile, err := ioutil.TempFile("", "computer_copy")
604-
gomega.Ω(err).Should(gomega.BeNil())
605-
err = tree.Download(instances[0].cli, path, dummyFile)
606-
gomega.Ω(err).Should(gomega.MatchError(tree.ErrMissing))
607-
dummyFile.Close()
608-
})
541+
for _, file := range []string{"computer.gif", "small.txt"} {
542+
var path string
543+
var originalFile *os.File
544+
var err error
545+
ginkgo.By("upload file", func() {
546+
originalFile, err = os.Open(file)
547+
gomega.Ω(err).Should(gomega.BeNil())
548+
549+
c := make(chan struct{})
550+
d := make(chan struct{})
551+
go func() {
552+
asyncBlockPush(instances[0], c)
553+
close(d)
554+
}()
555+
path, err = tree.Upload(context.Background(), instances[0].cli, priv, space, originalFile, 64*units.KiB)
556+
gomega.Ω(err).Should(gomega.BeNil())
557+
close(c)
558+
<-d
559+
})
560+
561+
var newFile *os.File
562+
ginkgo.By("download file", func() {
563+
newFile, err = ioutil.TempFile("", "computer")
564+
gomega.Ω(err).Should(gomega.BeNil())
565+
566+
err = tree.Download(instances[0].cli, path, newFile)
567+
gomega.Ω(err).Should(gomega.BeNil())
568+
})
569+
570+
ginkgo.By("compare file contents", func() {
571+
_, err = originalFile.Seek(0, io.SeekStart)
572+
gomega.Ω(err).Should(gomega.BeNil())
573+
rho := sha256.New()
574+
_, err = io.Copy(rho, originalFile)
575+
gomega.Ω(err).Should(gomega.BeNil())
576+
ho := fmt.Sprintf("%x", rho.Sum(nil))
577+
578+
_, err = newFile.Seek(0, io.SeekStart)
579+
gomega.Ω(err).Should(gomega.BeNil())
580+
rhn := sha256.New()
581+
_, err = io.Copy(rhn, newFile)
582+
gomega.Ω(err).Should(gomega.BeNil())
583+
hn := fmt.Sprintf("%x", rhn.Sum(nil))
584+
585+
gomega.Ω(ho).Should(gomega.Equal(hn))
586+
587+
originalFile.Close()
588+
newFile.Close()
589+
})
590+
591+
ginkgo.By("delete file", func() {
592+
c := make(chan struct{})
593+
d := make(chan struct{})
594+
go func() {
595+
asyncBlockPush(instances[0], c)
596+
close(d)
597+
}()
598+
err = tree.Delete(context.Background(), instances[0].cli, path, priv)
599+
gomega.Ω(err).Should(gomega.BeNil())
600+
close(c)
601+
<-d
602+
603+
// Should error
604+
dummyFile, err := ioutil.TempFile("", "computer_copy")
605+
gomega.Ω(err).Should(gomega.BeNil())
606+
err = tree.Download(instances[0].cli, path, dummyFile)
607+
gomega.Ω(err).Should(gomega.MatchError(tree.ErrMissing))
608+
dummyFile.Close()
609+
})
610+
}
609611
})
610612

611613
// TODO: full replicate blocks between nodes

tests/integration/small.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test

0 commit comments

Comments
 (0)