M8 networkmanager: the folder's unknown is the module's
The folder the two parts share says unknown module, so the node-engine does nothing inside it and the watcher reacts: a path it does not know is left as it is and written to its journal once per path, at its start and at the file event that makes it; the README says so. Builds: design 08 sign-in-page §12, §24, §25, §27; lead answer L-1 (hq 3a3a18a9)
This commit is contained in:
@@ -114,3 +114,52 @@ func TestTheWatchersSocketAnswersOneLine(t *testing.T) {
|
||||
t.Fatal("a closed socket answered")
|
||||
}
|
||||
}
|
||||
|
||||
// A path in the folder the watcher does not know is left as it is and written to its journal once per path: what is
|
||||
// there at its start, and what a file event makes after (§12; lead answer L-1).
|
||||
func TestAPathTheWatcherDoesNotKnowIsLeftAndSaidOnce(t *testing.T) {
|
||||
lines := journalLines(t)
|
||||
sys := &fakeSystem{}
|
||||
sys.set(guest(ratingFull))
|
||||
w := aWatcher(t, sys)
|
||||
f := w.Folder
|
||||
if _, err := f.keep(eventEnded, "s", map[string]string{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f.writeCheckAddress("http://check.example.net/")
|
||||
for _, p := range []string{filepath.Join(f.Dir, "notes.txt"), filepath.Join(f.Dir, pendingName, "stray")} {
|
||||
if err := os.WriteFile(p, []byte("x"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
made := make(chan string)
|
||||
w.Made = func(dirs []string, stop <-chan struct{}) <-chan string {
|
||||
if len(dirs) != 2 || dirs[0] != f.Dir || dirs[1] != filepath.Join(f.Dir, pendingName) {
|
||||
t.Errorf("watched %v", dirs)
|
||||
}
|
||||
return made
|
||||
}
|
||||
stop, done := make(chan struct{}), make(chan struct{})
|
||||
go func() { w.run(stop); close(done) }()
|
||||
for _, p := range []string{filepath.Join(f.Dir, "other"), filepath.Join(f.Dir, "other"), filepath.Join(f.Dir, "sequence.new"),
|
||||
filepath.Join(f.Dir, pendingName, "0000000002.json")} {
|
||||
made <- p
|
||||
}
|
||||
w.askLoop(askState)
|
||||
close(stop)
|
||||
<-done
|
||||
var said []string
|
||||
for _, l := range lines() {
|
||||
if strings.Contains(l, "is not the module's") {
|
||||
said = append(said, strings.TrimPrefix(l, f.Dir+"/"))
|
||||
}
|
||||
}
|
||||
want := []string{"notes.txt is not the module's: left as it is", "pending/stray is not the module's: left as it is",
|
||||
"other is not the module's: left as it is"}
|
||||
if strings.Join(said, "|") != strings.Join(want, "|") {
|
||||
t.Fatalf("said %q", said)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(f.Dir, "notes.txt")); err != nil {
|
||||
t.Fatal("a path the watcher does not know was not left")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user