2019-01-08 19:35:40 +00:00
|
|
|
package docker
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// TestMain is a hacky test entrypoint to set temp directory to a path that can
|
|
|
|
// be mounted into Docker containers on macOS without needing dev performing
|
|
|
|
// special setup.
|
|
|
|
//
|
2020-10-12 12:47:05 +00:00
|
|
|
// macOS sets tempdir as `/var`, which Docker does not allowlist as a path that
|
2019-01-08 19:35:40 +00:00
|
|
|
// can be bind-mounted.
|
|
|
|
func TestMain(m *testing.M) {
|
|
|
|
tmpdir := fmt.Sprintf("/tmp/nomad-docker-tests-%d", time.Now().Unix())
|
|
|
|
|
|
|
|
defer os.Setenv("TMPDIR", os.Getenv("TMPDIR"))
|
|
|
|
os.Setenv("TMPDIR", tmpdir)
|
|
|
|
|
|
|
|
os.MkdirAll(tmpdir, 0700)
|
|
|
|
defer os.RemoveAll(tmpdir)
|
|
|
|
|
|
|
|
os.Exit(m.Run())
|
|
|
|
}
|