(t *testing.T)
| 55 | } |
| 56 | |
| 57 | func TestFoldersProcessEventCurrentBehavior(t *testing.T) { |
| 58 | t.Parallel() |
| 59 | |
| 60 | watchPath := t.TempDir() |
| 61 | cfg := &FolderConfig{Path: watchPath} |
| 62 | folders := newTestFolders(t, cfg) |
| 63 | |
| 64 | archive := filepath.Join(watchPath, "movie.rar") |
| 65 | if err := os.WriteFile(archive, []byte("x"), 0o600); err != nil { |
| 66 | t.Fatalf("creating archive test file: %v", err) |
| 67 | } |
| 68 | |
| 69 | folders.processEvent(&eventData{ |
| 70 | cnfg: cfg, |
| 71 | name: filepath.Base(archive), |
| 72 | file: archive, |
| 73 | op: "test", |
| 74 | }, time.Now()) |
| 75 | |
| 76 | if _, ok := folders.Folders[archive]; !ok { |
| 77 | t.Fatalf("expected archive path to be tracked: %s", archive) |
| 78 | } |
| 79 | |
| 80 | plain := filepath.Join(watchPath, "note.txt") |
| 81 | if err := os.WriteFile(plain, []byte("x"), 0o600); err != nil { |
| 82 | t.Fatalf("creating non-archive test file: %v", err) |
| 83 | } |
| 84 | |
| 85 | folders.processEvent(&eventData{ |
| 86 | cnfg: cfg, |
| 87 | name: filepath.Base(plain), |
| 88 | file: plain, |
| 89 | op: "test", |
| 90 | }, time.Now()) |
| 91 | |
| 92 | if _, ok := folders.Folders[plain]; ok { |
| 93 | t.Fatalf("did not expect non-archive file to be tracked: %s", plain) |
| 94 | } |
| 95 | |
| 96 | dir := filepath.Join(watchPath, "incoming") |
| 97 | if err := os.Mkdir(dir, 0o700); err != nil { |
| 98 | t.Fatalf("creating folder test dir: %v", err) |
| 99 | } |
| 100 | |
| 101 | folders.processEvent(&eventData{ |
| 102 | cnfg: cfg, |
| 103 | name: filepath.Base(dir), |
| 104 | file: dir, |
| 105 | op: "test", |
| 106 | }, time.Now()) |
| 107 | |
| 108 | if _, ok := folders.Folders[dir]; !ok { |
| 109 | t.Fatalf("expected folder path to be tracked: %s", dir) |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | func TestFoldersProcessEventExcludedPath(t *testing.T) { |
| 114 | t.Parallel() |
nothing calls this directly
no test coverage detected