cleanup fooPodContainerDir in /tmp

Signed-off-by: Jess Frazelle <acidburn@google.com>
This commit is contained in:
Jess Frazelle 2016-12-14 16:47:53 -08:00
parent b5da2d13a6
commit 7db9c8b454
No known key found for this signature in database
GPG Key ID: 18F3685C0022BFF3

View File

@ -17,6 +17,7 @@ limitations under the License.
package dockertools
import (
"flag"
"fmt"
"io/ioutil"
"net"
@ -58,6 +59,21 @@ import (
"k8s.io/kubernetes/pkg/util/sets"
)
var testTempDir string
func TestMain(m *testing.M) {
dir, err := ioutil.TempDir("", "dockertools")
if err != nil {
panic(err)
}
testTempDir = dir
flag.Parse()
status := m.Run()
os.RemoveAll(testTempDir)
os.Exit(status)
}
type fakeHTTP struct {
url string
err error
@ -80,7 +96,7 @@ func (f *fakeRuntimeHelper) GenerateRunContainerOptions(pod *v1.Pod, container *
var opts kubecontainer.RunContainerOptions
var err error
if len(container.TerminationMessagePath) != 0 {
testPodContainerDir, err = ioutil.TempDir("", "fooPodContainerDir")
testPodContainerDir, err = ioutil.TempDir(testTempDir, "fooPodContainerDir")
if err != nil {
return nil, err
}