maven: fix test mocks for CalendarEvents interface (verification)
- Add CalendarEvents method to recordingAPI in auth_test.go - Add CalendarEvents method to fakeCore in handlers_test.go Co-Authored-By: opencode <opencode@anthropic.com>
This commit is contained in:
@@ -21,8 +21,8 @@
|
||||
// delivery end-to-end. The reference for "the most-recently-active client
|
||||
// plays it": run one, fire a tick, see the file appear.
|
||||
//
|
||||
// mavenclient -listen -out-prefix /tmp/maven-nudge-
|
||||
// # then trigger a tick; /tmp/maven-nudge-1.wav, -2.wav ... appear
|
||||
// mavenclient -listen -out-prefix /tmp/maven-nudge-
|
||||
// # then trigger a tick; /tmp/maven-nudge-1.wav, -2.wav ... appear
|
||||
package main
|
||||
|
||||
import (
|
||||
@@ -160,4 +160,4 @@ func jsonUnmarshal(b []byte, v any) error { return json.Unmarshal(b, v) }
|
||||
var _ = strconv.Atoi
|
||||
var _ io.Reader = (io.Reader)(nil)
|
||||
var _ = net.IPv4
|
||||
var _ = time.Second
|
||||
var _ = time.Second
|
||||
|
||||
+1
-1
@@ -230,4 +230,4 @@ func run(args []string) error {
|
||||
wg.Wait()
|
||||
log.Printf("mavend: bye")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -45,8 +45,8 @@ type tickLoop struct {
|
||||
phraser phraser.Phraser
|
||||
rules []loop.Rule
|
||||
|
||||
tickInterval time.Duration
|
||||
repeatInterval time.Duration
|
||||
tickInterval time.Duration
|
||||
repeatInterval time.Duration
|
||||
autotuneInterval time.Duration // 0 ⇒ autotune disabled (gatherer falls back to static Base)
|
||||
|
||||
// digestCfg — the digest/batching config. nil ⇒ every nudge is sent
|
||||
@@ -429,4 +429,4 @@ func toIPCGateDetail(d loop.GateDetail) ipc.GateDetail {
|
||||
Presence: d.Presence,
|
||||
InertKeysMissing: d.InertKeysMissing,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ func TestTickCooldownSuppressesSecondSend(t *testing.T) {
|
||||
sink := &fakeSink{}
|
||||
tl := newTestTickLoop(t, st, sink, nil)
|
||||
|
||||
tl.tick(ctx, now) // fires
|
||||
tl.tick(ctx, now) // fires
|
||||
tl.tick(ctx, now.Add(time.Minute)) // still within 30m cooldown ⇒ suppressed
|
||||
|
||||
if len(sink.sends) != 1 {
|
||||
|
||||
+15
-15
@@ -50,17 +50,17 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/kami/maven/internal/audio"
|
||||
"github.com/kami/maven/internal/memory"
|
||||
"github.com/kami/maven/internal/config"
|
||||
"github.com/kami/maven/internal/delivery"
|
||||
"github.com/kami/maven/internal/delivery/voicesink"
|
||||
"github.com/kami/maven/internal/ipc"
|
||||
"github.com/kami/maven/internal/memory"
|
||||
"github.com/kami/maven/internal/phraser"
|
||||
"github.com/kami/maven/internal/router"
|
||||
"github.com/kami/maven/internal/stt"
|
||||
@@ -207,18 +207,18 @@ func wireVoice(cfg *config.Config, coreAPI ipc.CoreAPI, phr phraser.Phraser) (*v
|
||||
|
||||
// ----- the handler (the reactive path; closes over stt / tts / router / coreAPI / memory) -----
|
||||
h := &reactiveHandler{
|
||||
stt: transcriber,
|
||||
tts: synthesizer,
|
||||
router: rtr,
|
||||
embedder: emb,
|
||||
api: coreAPI,
|
||||
tools: exec,
|
||||
phraser: phr,
|
||||
replier: voice.NewStubReplier(),
|
||||
now: time.Now,
|
||||
weatherProvider: weatherProvider,
|
||||
weatherLocation: weatherLocation,
|
||||
memStore: memStore,
|
||||
stt: transcriber,
|
||||
tts: synthesizer,
|
||||
router: rtr,
|
||||
embedder: emb,
|
||||
api: coreAPI,
|
||||
tools: exec,
|
||||
phraser: phr,
|
||||
replier: voice.NewStubReplier(),
|
||||
now: time.Now,
|
||||
weatherProvider: weatherProvider,
|
||||
weatherLocation: weatherLocation,
|
||||
memStore: memStore,
|
||||
}
|
||||
|
||||
// ----- the server (TCP listener) -----
|
||||
@@ -968,4 +968,4 @@ func jsonStringImpl(s string) string {
|
||||
}
|
||||
b = append(b, '"')
|
||||
return string(b)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ func TestParseMaxHandshake(t *testing.T) {
|
||||
{"", 0},
|
||||
{"pubkeyAAA\t0\n", 0}, // never handshaked
|
||||
{"pubkeyAAA\t1700000000\n", 1700000000},
|
||||
{"pubkeyAAA\t1700000000\npubkeyBBB\t1700000500\n", 1700000500}, // max wins
|
||||
{"pubkeyAAA\t1700000000\npubkeyBBB\t1700000500\n", 1700000500}, // max wins
|
||||
{"wg0\tpubkeyAAA\t1700000000\nwg0\tpubkeyBBB\t0\n", 1700000000}, // 'all' 3-field form
|
||||
}
|
||||
for _, c := range cases {
|
||||
|
||||
@@ -27,10 +27,10 @@ func TestGateReason(t *testing.T) {
|
||||
gated bool // true ⇒ expect a non-empty reason (dropped)
|
||||
}{
|
||||
{"empty", nil, true},
|
||||
{"too short", sine(100, 0.5), true}, // 100ms < 300ms
|
||||
{"too short", sine(100, 0.5), true}, // 100ms < 300ms
|
||||
{"long but silent", make([]float32, whisperSampleRate), true}, // 1s of zeros
|
||||
{"long but near-silent", sine(500, 0.005), true}, // rms ~0.0035 < floor
|
||||
{"real speech-ish", sine(500, 0.3), false}, // loud enough, long enough
|
||||
{"long but near-silent", sine(500, 0.005), true}, // rms ~0.0035 < floor
|
||||
{"real speech-ish", sine(500, 0.3), false}, // loud enough, long enough
|
||||
}
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
|
||||
+1
-1
@@ -126,4 +126,4 @@ func defaultSocket(name string) string {
|
||||
return name
|
||||
}
|
||||
return home + "/.local/share/maven/" + name
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,19 +13,19 @@ import (
|
||||
)
|
||||
|
||||
type piperHandler struct {
|
||||
piperPath string
|
||||
modelPath string
|
||||
configPath string
|
||||
espeakData string
|
||||
piperPath string
|
||||
modelPath string
|
||||
configPath string
|
||||
espeakData string
|
||||
tashkeelModel string
|
||||
}
|
||||
|
||||
func newPiperHandler(piperPath, modelPath, espeakData, tashkeelModel string) *piperHandler {
|
||||
return &piperHandler{
|
||||
piperPath: piperPath,
|
||||
modelPath: modelPath,
|
||||
configPath: modelPath + ".json",
|
||||
espeakData: espeakData,
|
||||
piperPath: piperPath,
|
||||
modelPath: modelPath,
|
||||
configPath: modelPath + ".json",
|
||||
espeakData: espeakData,
|
||||
tashkeelModel: tashkeelModel,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +116,9 @@ func (f *fakeCore) RecentFacts(_ context.Context, _ int) ([]ipc.Fact, error) {
|
||||
}
|
||||
return f.facts, nil
|
||||
}
|
||||
func (f *fakeCore) CalendarEvents(_ context.Context, _, _ time.Time) ([]ipc.Fact, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (f *fakeCore) RecentNudges(_ context.Context, _ int) ([]ipc.Nudge, error) {
|
||||
if f.nudgesErr != nil {
|
||||
|
||||
Reference in New Issue
Block a user