Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aduffeck committed Jan 9, 2024
1 parent a5f9fa7 commit 717c1c6
Showing 1 changed file with 3 additions and 42 deletions.
45 changes: 3 additions & 42 deletions pkg/storage/utils/decomposedfs/upload_test.go
Expand Up @@ -230,6 +230,8 @@ var _ = Describe("File uploads", func() {

When("the user initiates a zero byte file upload", func() {
It("succeeds", func() {
bs.On("Upload", mock.AnythingOfType("*node.Node"), mock.AnythingOfType("string"), mock.Anything).
Return(nil)
uploadIds, err := fs.InitiateUpload(ctx, ref, 0, map[string]string{})

Expect(err).ToNot(HaveOccurred())
Expand All @@ -239,7 +241,7 @@ var _ = Describe("File uploads", func() {

resources, err := fs.ListFolder(ctx, rootRef, []string{}, []string{})
Expect(err).ToNot(HaveOccurred())
Expect(len(resources)).To(Equal(0))
Expect(len(resources)).To(Equal(1))
})
})

Expand Down Expand Up @@ -284,47 +286,6 @@ var _ = Describe("File uploads", func() {
})
})

When("the user uploads a zero byte file", func() {
It("succeeds", func() {
var (
fileContent = []byte("")
)

uploadIds, err := fs.InitiateUpload(ctx, ref, 0, map[string]string{})

Expect(err).ToNot(HaveOccurred())
Expect(len(uploadIds)).To(Equal(2))
Expect(uploadIds["simple"]).ToNot(BeEmpty())
Expect(uploadIds["tus"]).ToNot(BeEmpty())

uploadRef := &provider.Reference{Path: "/" + uploadIds["simple"]}

bs.On("Upload", mock.AnythingOfType("*node.Node"), mock.AnythingOfType("string"), mock.Anything).
Return(nil).
Run(func(args mock.Arguments) {
data, err := os.ReadFile(args.Get(1).(string))

Expect(err).ToNot(HaveOccurred())
Expect(data).To(Equal([]byte("")))
})

_, err = fs.Upload(ctx, storage.UploadRequest{
Ref: uploadRef,
Body: io.NopCloser(bytes.NewReader(fileContent)),
Length: int64(len(fileContent)),
}, nil)

Expect(err).ToNot(HaveOccurred())
bs.AssertCalled(GinkgoT(), "Upload", mock.Anything, mock.Anything, mock.Anything)

resources, err := fs.ListFolder(ctx, rootRef, []string{}, []string{})

Expect(err).ToNot(HaveOccurred())
Expect(len(resources)).To(Equal(1))
Expect(resources[0].Path).To(Equal(ref.Path))
})
})

When("the user tries to upload a file without intialising the upload", func() {
It("fails", func() {
var (
Expand Down

0 comments on commit 717c1c6

Please sign in to comment.