feat: add inbox
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func TestDefaultConfig(t *testing.T) {
|
||||
t.Setenv("USER", "example")
|
||||
cfg := Default()
|
||||
if !cfg.Events.Stop {
|
||||
t.Fatal("expected stop=true by default")
|
||||
@@ -17,6 +18,24 @@ func TestDefaultConfig(t *testing.T) {
|
||||
if cfg.Notify.Protocol != "osc777" {
|
||||
t.Fatalf("expected osc777, got %q", cfg.Notify.Protocol)
|
||||
}
|
||||
if !cfg.Inbox.Enabled {
|
||||
t.Fatal("expected inbox enabled by default")
|
||||
}
|
||||
if cfg.Inbox.Addr != "127.0.0.1:17777" {
|
||||
t.Fatalf("expected default inbox addr, got %q", cfg.Inbox.Addr)
|
||||
}
|
||||
if cfg.Inbox.Socket == "" {
|
||||
t.Fatal("expected default inbox socket")
|
||||
}
|
||||
if cfg.Inbox.RemoteSocket != "/tmp/agent-notify-example.sock" {
|
||||
t.Fatalf("expected default remote socket, got %q", cfg.Inbox.RemoteSocket)
|
||||
}
|
||||
if !cfg.Inbox.FallbackLocal {
|
||||
t.Fatal("expected local fallback enabled by default")
|
||||
}
|
||||
if cfg.Inbox.TimeoutMS != 500 {
|
||||
t.Fatalf("expected 500ms timeout, got %d", cfg.Inbox.TimeoutMS)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadFromFile(t *testing.T) {
|
||||
@@ -29,6 +48,14 @@ tool = true
|
||||
|
||||
[notify]
|
||||
body_stop = "custom stop"
|
||||
|
||||
[inbox]
|
||||
enabled = false
|
||||
socket = "/tmp/custom-agent-notify.sock"
|
||||
remote_socket = "/tmp/custom-remote-agent-notify.sock"
|
||||
addr = "127.0.0.1:18888"
|
||||
fallback_local = false
|
||||
timeout_ms = 250
|
||||
`
|
||||
if err := os.WriteFile(path, []byte(content), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -46,6 +73,35 @@ body_stop = "custom stop"
|
||||
if cfg.Notify.BodyStop != "custom stop" {
|
||||
t.Fatalf("got %q", cfg.Notify.BodyStop)
|
||||
}
|
||||
if cfg.Inbox.Enabled {
|
||||
t.Fatal("expected inbox disabled")
|
||||
}
|
||||
if cfg.Inbox.Socket != "/tmp/custom-agent-notify.sock" {
|
||||
t.Fatalf("got inbox socket %q", cfg.Inbox.Socket)
|
||||
}
|
||||
if cfg.Inbox.RemoteSocket != "/tmp/custom-remote-agent-notify.sock" {
|
||||
t.Fatalf("got inbox remote socket %q", cfg.Inbox.RemoteSocket)
|
||||
}
|
||||
if cfg.Inbox.Addr != "127.0.0.1:18888" {
|
||||
t.Fatalf("got inbox addr %q", cfg.Inbox.Addr)
|
||||
}
|
||||
if cfg.Inbox.FallbackLocal {
|
||||
t.Fatal("expected fallback_local=false")
|
||||
}
|
||||
if cfg.Inbox.TimeoutMS != 250 {
|
||||
t.Fatalf("got timeout %d", cfg.Inbox.TimeoutMS)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultInboxSocketPrefersXDGRuntimeDir(t *testing.T) {
|
||||
t.Setenv("XDG_RUNTIME_DIR", "/run/user/1234")
|
||||
t.Setenv("HOME", "/home/example")
|
||||
|
||||
got := DefaultInboxSocket()
|
||||
want := "/run/user/1234/agent-notify.sock"
|
||||
if got != want {
|
||||
t.Fatalf("got %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEventEnabled(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user