MCPcopy Create free account
hub / github.com/Unpackerr/unpackerr / TestFoldersProcessEventCurrentBehavior

Function TestFoldersProcessEventCurrentBehavior

pkg/unpackerr/folder_test.go:57–111  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

55}
56
57func 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
113func TestFoldersProcessEventExcludedPath(t *testing.T) {
114 t.Parallel()

Callers

nothing calls this directly

Calls 2

newTestFoldersFunction · 0.85
processEventMethod · 0.45

Tested by

no test coverage detected