ADR 0378 §9 as amended by ADR 0379: a module of its own, built from mesh-mail's event shape, runs as its own account to hear mesh-mail's restricted MAIL stream (ADR 0376 §2), shows each new inbox mail through node-notifier.send at most once, folds more than three from one account into one notice, and emits its own shown event.
32 lines
965 B
Go
32 lines
965 B
Go
package main
|
|
|
|
// mesh-mail-notifier carries a byte-identical copy of mesh-mail's event shape (novox/hq ADR 0378 §9, issue 800
|
|
// part B), the way modules/networkmanager's uplink-tools carries ifwatchd's own file (ADR 0241, copies_test.go):
|
|
// each builds alone, so each holds its own copy, and this test holds them to one text.
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
// source is where mesh-mail's own copy of the file lives.
|
|
var source = filepath.Join("..", "..", "..", "mesh-mail", "cmd", "mesh-mail")
|
|
|
|
func TestCarriesTheSameMailEventAsMeshMail(t *testing.T) {
|
|
for _, f := range []string{"mailevent.go"} {
|
|
mine, err := os.ReadFile(f)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
theirs, err := os.ReadFile(filepath.Join(source, f))
|
|
if err != nil {
|
|
t.Fatalf("mesh-mail's copy of %s could not be read: %v", f, err)
|
|
}
|
|
if !bytes.Equal(mine, theirs) {
|
|
t.Errorf("this copy of %s differs from mesh-mail's: change both together", f)
|
|
}
|
|
}
|
|
}
|