diff --git a/server/filesystem/compress_test.go b/server/filesystem/compress_test.go index 80cf7080..1878c1fc 100644 --- a/server/filesystem/compress_test.go +++ b/server/filesystem/compress_test.go @@ -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") + }) + } + }) +} \ No newline at end of file diff --git a/server/filesystem/testdata/test_13b.rar b/server/filesystem/testdata/test_13b.rar new file mode 100644 index 00000000..b08e2f35 Binary files /dev/null and b/server/filesystem/testdata/test_13b.rar differ diff --git a/server/filesystem/testdata/test_13b.tar b/server/filesystem/testdata/test_13b.tar new file mode 100644 index 00000000..2a6a7694 Binary files /dev/null and b/server/filesystem/testdata/test_13b.tar differ diff --git a/server/filesystem/testdata/test_13b.tar.gz b/server/filesystem/testdata/test_13b.tar.gz new file mode 100644 index 00000000..ee33844c Binary files /dev/null and b/server/filesystem/testdata/test_13b.tar.gz differ diff --git a/server/filesystem/testdata/test_13b.zip b/server/filesystem/testdata/test_13b.zip new file mode 100644 index 00000000..da312006 Binary files /dev/null and b/server/filesystem/testdata/test_13b.zip differ