(t *testing.T)
| 111 | } |
| 112 | |
| 113 | func TestFoldersProcessEventExcludedPath(t *testing.T) { |
| 114 | t.Parallel() |
| 115 | |
| 116 | watchPath := t.TempDir() |
| 117 | |
| 118 | excluded := filepath.Join(watchPath, "permanent") |
| 119 | if err := os.MkdirAll(filepath.Join(excluded, "sub"), 0o700); err != nil { |
| 120 | t.Fatalf("creating excluded test path: %v", err) |
| 121 | } |
| 122 | |
| 123 | nested := filepath.Join(excluded, "sub", "file.rar") |
| 124 | if err := os.WriteFile(nested, []byte("x"), 0o600); err != nil { |
| 125 | t.Fatalf("creating nested archive file: %v", err) |
| 126 | } |
| 127 | |
| 128 | cfg := &FolderConfig{ |
| 129 | Path: watchPath, |
| 130 | ExcludePaths: []string{excluded}, |
| 131 | } |
| 132 | folders := newTestFolders(t, cfg) |
| 133 | |
| 134 | // Direct excluded folder. |
| 135 | folders.processEvent(&eventData{ |
| 136 | cnfg: cfg, |
| 137 | name: "permanent", |
| 138 | file: excluded, |
| 139 | op: "test", |
| 140 | }, time.Now()) |
| 141 | |
| 142 | if len(folders.Folders) != 0 { |
| 143 | t.Fatalf("expected no tracked folders for excluded path, got: %v", folders.Folders) |
| 144 | } |
| 145 | |
| 146 | // Nested event from an excluded folder should also be ignored. |
| 147 | folders.processEvent(&eventData{ |
| 148 | cnfg: cfg, |
| 149 | name: "sub", |
| 150 | file: nested, |
| 151 | op: "test", |
| 152 | }, time.Now()) |
| 153 | |
| 154 | if len(folders.Folders) != 0 { |
| 155 | t.Fatalf("expected no tracked folders for nested excluded event, got: %v", folders.Folders) |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | func TestFoldersHandleFileEventExcludedPath(t *testing.T) { |
| 160 | t.Parallel() |
nothing calls this directly
no test coverage detected