claude-code: drop what was removed while away, render one at a time, refuse an empty settings set
Review of the nox-mesh plugin: a watch hands over what is there, not what went, so the view is pruned to the state's keys before it starts; the watches and the tools render one at a time, as the home's record is read and written whole; the register answer names how an item is offered.
This commit is contained in:
@@ -318,3 +318,24 @@ func TestATreeIsTheSameOnlyWhenEveryFileAndModeIs(t *testing.T) {
|
||||
t.Fatal("an extra file counted as the same")
|
||||
}
|
||||
}
|
||||
|
||||
// A registration removed while a node was away is dropped when it is back: the watch hands over only what is
|
||||
// there, so the view is pruned to the keys the state still holds.
|
||||
func TestWhatWasRemovedWhileANodeWasAwayIsDropped(t *testing.T) {
|
||||
p, w := node(t, "laptop")
|
||||
state, view := memConfig{}, NewConfigView(p)
|
||||
for _, name := range []string{"kept", "gone"} {
|
||||
if _, err := Register(p, Item{Kind: KindCommand, Name: name, Scope: ScopeMesh, Files: one(name, "x")}, nil, false, state, view, writer(w)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
delete(state, "mesh.command.gone") // removed from another node while this one was off
|
||||
back := NewConfigView(p) // the node starts again from what it last wrote
|
||||
if len(back.Items()) != 2 {
|
||||
t.Fatalf("the view did not start from what was last written: %v", back.Items())
|
||||
}
|
||||
keys, _ := state.Keys()
|
||||
if !back.Prune(keys) || len(back.Items()) != 1 {
|
||||
t.Fatalf("after pruning: %v", back.Items())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user