MCPcopy
hub / github.com/pocketbase/pocketbase / TestFileSystemCopy

Function TestFileSystemCopy

tools/filesystem/filesystem_test.go:704–736  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

702}
703
704func TestFileSystemCopy(t *testing.T) {
705 dir := createTestDir(t)
706 defer os.RemoveAll(dir)
707
708 fsys, err := filesystem.NewLocal(dir)
709 if err != nil {
710 t.Fatal(err)
711 }
712 defer fsys.Close()
713
714 src := "image.png"
715 dst := "image.png_copy"
716
717 // copy missing file
718 if err := fsys.Copy(dst, src); err == nil {
719 t.Fatalf("Expected to fail copying %q to %q, got nil", dst, src)
720 }
721
722 // copy existing file
723 if err := fsys.Copy(src, dst); err != nil {
724 t.Fatalf("Failed to copy %q to %q: %v", src, dst, err)
725 }
726
727 f, err := fsys.GetReader(dst)
728 if err != nil {
729 t.Fatalf("Missing copied file %q: %v", dst, err)
730 }
731 defer f.Close()
732
733 if f.Size() != 73 {
734 t.Fatalf("Expected file size %d, got %d", 73, f.Size())
735 }
736}
737
738func TestFileSystemList(t *testing.T) {
739 dir := createTestDir(t)

Callers

nothing calls this directly

Calls 7

NewLocalFunction · 0.92
GetReaderMethod · 0.80
SizeMethod · 0.80
createTestDirFunction · 0.70
CloseMethod · 0.65
CopyMethod · 0.65
RemoveAllMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…