MCPcopy
hub / github.com/pocketbase/pocketbase / TestFileSystemList

Function TestFileSystemList

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

Source from the content-addressed store, hash-verified

736}
737
738func TestFileSystemList(t *testing.T) {
739 dir := createTestDir(t)
740 defer os.RemoveAll(dir)
741
742 fsys, err := filesystem.NewLocal(dir)
743 if err != nil {
744 t.Fatal(err)
745 }
746 defer fsys.Close()
747
748 scenarios := []struct {
749 prefix string
750 expected []string
751 }{
752 {
753 "",
754 []string{
755 "image.png",
756 "image.jpg",
757 "image.svg",
758 "image.webp",
759 "image_!@ special",
760 "image_noext",
761 "style.css",
762 "main.js",
763 "main.mjs",
764 "dummy.xlsx",
765 "dummy.docx",
766 "dummy.pptx",
767 "test/sub1.txt",
768 "test/sub2.txt",
769 },
770 },
771 {
772 "test",
773 []string{
774 "test/sub1.txt",
775 "test/sub2.txt",
776 },
777 },
778 {
779 "missing",
780 []string{},
781 },
782 }
783
784 for _, s := range scenarios {
785 t.Run("prefix_"+s.prefix, func(t *testing.T) {
786 objs, err := fsys.List(s.prefix)
787 if err != nil {
788 t.Fatal(err)
789 }
790
791 if len(s.expected) != len(objs) {
792 t.Fatalf("Expected %d files, got \n%v", len(s.expected), objs)
793 }
794
795 for _, obj := range objs {

Callers

nothing calls this directly

Calls 6

NewLocalFunction · 0.92
createTestDirFunction · 0.70
CloseMethod · 0.65
RemoveAllMethod · 0.45
RunMethod · 0.45
ListMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…