]> git.giacomolli.uk - onechat/blobdiff - daemon_start_helper_test.go
Order model and chat declarations
[onechat] / daemon_start_helper_test.go
index c43ff9cb58989ab31141e837388205a835f959a2..b09c11be0679f2e2b1457e08622c98fa4ab26b24 100644 (file)
@@ -2,6 +2,7 @@ package main
 
 import (
        "context"
+       "os"
        "path/filepath"
        "testing"
        "time"
@@ -65,3 +66,19 @@ func daemonStartTestWithSchedules(t *testing.T, server *ModelFake, bot *Telegram
 
        return socket, memory
 }
+
+// socketTestDir returns a new short directory under /tmp for data that holds a
+// daemon socket. t.TempDir holds the test name and the TMPDIR of the shell, so
+// its paths can pass the 107-byte limit of a Unix socket path.
+func socketTestDir(t *testing.T) string {
+       t.Helper()
+
+       dir, err := os.MkdirTemp("/tmp", "onechat-")
+       require.NoError(t, err)
+
+       t.Cleanup(func() {
+               require.NoError(t, os.RemoveAll(dir))
+       })
+
+       return dir
+}