github.com/ilhicas/nomad@v0.11.8/drivers/docker/driver_darwin_test.go (about) 1 package docker 2 3 import ( 4 "fmt" 5 "os" 6 "testing" 7 "time" 8 ) 9 10 // TestMain is a hacky test entrypoint to set temp directory to a path that can 11 // be mounted into Docker containers on macOS without needing dev performing 12 // special setup. 13 // 14 // macOS sets tempdir as `/var`, which Docker does not whitelist as a path that 15 // can be bind-mounted. 16 func TestMain(m *testing.M) { 17 tmpdir := fmt.Sprintf("/tmp/nomad-docker-tests-%d", time.Now().Unix()) 18 19 defer os.Setenv("TMPDIR", os.Getenv("TMPDIR")) 20 os.Setenv("TMPDIR", tmpdir) 21 22 os.MkdirAll(tmpdir, 0700) 23 defer os.RemoveAll(tmpdir) 24 25 os.Exit(m.Run()) 26 }