X-Git-Url: http://git.giacomolli.uk/onechat/blobdiff_plain/97274864799ac2eea84bf80c9727a810b695db55..b2873a2a0bf8b0ba648aebac51759e5fed89a2e2:/daemon_test.go?ds=inline diff --git a/daemon_test.go b/daemon_test.go index 91d6ecc..00680e6 100644 --- a/daemon_test.go +++ b/daemon_test.go @@ -116,6 +116,18 @@ func TestListenSocketRefusesALongPath(t *testing.T) { require.ErrorContains(t, err, "set ONECHAT_DIR to a shorter path") } +func TestDaemonWritesNoFileForALongSocketPath(t *testing.T) { + dir := filepath.Join(t.TempDir(), strings.Repeat("d", 100)) + t.Setenv("ONECHAT_DIR", dir) + + err := daemon(t.Context(), io.Discard) + require.ErrorContains(t, err, "set ONECHAT_DIR to a shorter path") + + entries, err := os.ReadDir(dir) + require.NoError(t, err) + require.Empty(t, entries) +} + func TestOneProcessHoldsTheTokens(t *testing.T) { dir := t.TempDir() lock, err := lockTokens(dir) @@ -142,10 +154,15 @@ func TestEventText(t *testing.T) { text: "Done.", }, { - name: "user message not shown", - event: Event{Kind: "user", Text: "typed"}, + name: "own user message not shown", + event: Event{Kind: "user", Text: "typed", Source: terminalSource}, text: "", }, + { + name: "user message of another source marked", + event: Event{Kind: "user", Text: "from the phone", Source: "telegram"}, + text: "[telegram] from the phone", + }, { name: "long result cut", event: Event{Kind: "echo", Text: strings.Repeat("line\n", 12)},