]> git.giacomolli.uk - onechat/blob - socket_helper_test.go
Keep test daemon sockets under the path limit
[onechat] / socket_helper_test.go
1 package main
2
3 import (
4 "os"
5 "testing"
6
7 "github.com/stretchr/testify/require"
8 )
9
10 // socketTestDir returns a new short directory under /tmp for data that holds a
11 // daemon socket. t.TempDir holds the test name and the TMPDIR of the shell, so
12 // its paths can pass the 107-byte limit of a Unix socket path.
13 func socketTestDir(t *testing.T) string {
14 t.Helper()
15
16 dir, err := os.MkdirTemp("/tmp", "onechat-")
17 require.NoError(t, err)
18
19 t.Cleanup(func() {
20 require.NoError(t, os.RemoveAll(dir))
21 })
22
23 return dir
24 }