Skip to content

Commit

Permalink
Add a simple test for regression
Browse files Browse the repository at this point in the history
Co-authored-by: Arnaud Lier <[email protected]>
  • Loading branch information
Linux123123 and ArnaudLier committed Jan 4, 2025
1 parent f3fed4b commit 229c8af
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions server/filesystem/compress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,38 @@ func TestFilesystem_DecompressFile(t *testing.T) {
})
})
}

func TestFilesystem_SpaceAvailableForDecompression(t *testing.T) {
g := Goblin(t)
fs, rfs := NewFs()

g.Describe("SpaceAvailableForDecompression", func() {
for _, ext := range []string{"zip", "rar", "tar", "tar.gz"} {
g.It("should succeed when enough space is available for decompression of a "+ext, func() {
fs.SetDiskLimit(2048)

// copy the file to the new FS
c, err := os.ReadFile("./testdata/test." + ext)
g.Assert(err).IsNil()
err = rfs.CreateServerFile("./test."+ext, c)
g.Assert(err).IsNil()

err = fs.SpaceAvailableForDecompression(context.Background(), "./", "test."+ext)
g.Assert(err).IsNil()
})

g.It("should fail when not enough space is available for decompression of a "+ext, func() {
fs.SetDiskLimit(12)

// copy the file to the new FS
c, err := os.ReadFile("./testdata/test_13b." + ext)
g.Assert(err).IsNil()
err = rfs.CreateServerFile("./test_13b."+ext, c)
g.Assert(err).IsNil()

err = fs.SpaceAvailableForDecompression(context.Background(), "./", "test_13b."+ext)
g.Assert(err.Error()).Equal("filesystem: not enough disk space")
})
}
})
}
Binary file added server/filesystem/testdata/test_13b.rar
Binary file not shown.
Binary file added server/filesystem/testdata/test_13b.tar
Binary file not shown.
Binary file added server/filesystem/testdata/test_13b.tar.gz
Binary file not shown.
Binary file added server/filesystem/testdata/test_13b.zip
Binary file not shown.

0 comments on commit 229c8af

Please sign in to comment.