MCPcopy
hub / github.com/syncthing/syncthing / TestIncludedSubdir

Function TestIncludedSubdir

lib/scanner/walk_test.go:886–927  ·  view source on GitHub ↗

https://github.com/syncthing/syncthing/issues/6487

(t *testing.T)

Source from the content-addressed store, hash-verified

884
885// https://github.com/syncthing/syncthing/issues/6487
886func TestIncludedSubdir(t *testing.T) {
887 fss := fs.NewFilesystem(fs.FilesystemTypeFake, "")
888
889 name := filepath.Clean("foo/bar/included")
890 err := fss.MkdirAll(name, 0o777)
891 if err != nil {
892 t.Fatal(err)
893 }
894
895 pats := ignore.New(fss, ignore.WithCache(true))
896
897 stignore := `
898 !/foo/bar
899 *
900 `
901 if err := pats.Parse(bytes.NewBufferString(stignore), ".stignore"); err != nil {
902 t.Fatal(err)
903 }
904
905 fchan := Walk(context.TODO(), Config{
906 CurrentFiler: make(fakeCurrentFiler),
907 Filesystem: fss,
908 Matcher: pats,
909 })
910
911 found := false
912 for f := range fchan {
913 if f.Err != nil {
914 t.Fatalf("Error while scanning %v: %v", f.Err, f.Path)
915 }
916 if f.File.IsIgnored() {
917 t.Error("File is ignored:", f.File.Name)
918 }
919 if f.File.Name == name {
920 found = true
921 }
922 }
923
924 if !found {
925 t.Errorf("File not present in scan results")
926 }
927}
928
929// Verify returns nil or an error describing the mismatch between the block
930// list and actual reader contents

Callers

nothing calls this directly

Calls 10

MkdirAllMethod · 0.95
NewFilesystemFunction · 0.92
NewFunction · 0.92
WithCacheFunction · 0.92
WalkFunction · 0.85
FatalMethod · 0.80
ParseMethod · 0.80
CleanMethod · 0.65
ErrorMethod · 0.65
IsIgnoredMethod · 0.45

Tested by

no test coverage detected