summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
inline | side by side (from parent 1:
b1be0ee)
The test daemon keeps its data, and so its socket, in a short directory
under /tmp. t.TempDir holds the test name and the long TMPDIR of the
development shell, so a test with a long name failed to listen on a
socket path over 107 bytes, and bin/check failed in the shell unless
TMPDIR was set short by hand.
func daemonStartTestWithSchedules(t *testing.T, server *ModelFake, bot *TelegramBot, whatsapp *WhatsApp, schedules *Schedules, clock func() time.Time) (string, *Memory) {
t.Helper()
func daemonStartTestWithSchedules(t *testing.T, server *ModelFake, bot *TelegramBot, whatsapp *WhatsApp, schedules *Schedules, clock func() time.Time) (string, *Memory) {
t.Helper()
+ dir := socketTestDir(t)
agent, err := openAgent(filepath.Join(dir, daemonAgentDirName))
require.NoError(t, err)
agent, err := openAgent(filepath.Join(dir, daemonAgentDirName))
require.NoError(t, err)
--- /dev/null
+package main
+
+import (
+ "os"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+// 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
+}