X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/195c3fbb075383ac47bba310eb701b02774e8d10..80e348724041a694002fc38f57e8868b9b9a2be9:/daemon_start_helper_test.go diff --git a/daemon_start_helper_test.go b/daemon_start_helper_test.go index c43ff9c..b09c11b 100644 --- a/daemon_start_helper_test.go +++ b/daemon_start_helper_test.go @@ -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 +}