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)
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)},