mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-30 00:07:59 +00:00
18 lines
381 B
Go
18 lines
381 B
Go
package testing
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
// TempDir creates a temporary directory and returns its path along
|
|
// with a cleanup function to be called via defer, ex:
|
|
// dir, cleanup := TempDir()
|
|
// defer cleanup()
|
|
func TempDir(t *testing.T) (string, func()) {
|
|
tmpDir, err := ioutil.TempDir("", "")
|
|
Ok(t, err)
|
|
return tmpDir, func() { os.RemoveAll(tmpDir) }
|
|
}
|