pkg/system: fix cleanup in tests

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
This commit is contained in:
unclejack 2014-11-20 19:33:15 +02:00
parent 3e5cb0c84f
commit 769b79866a
3 changed files with 10 additions and 5 deletions

View File

@ -1,11 +1,13 @@
package system package system
import ( import (
"os"
"testing" "testing"
) )
func TestLstat(t *testing.T) { func TestLstat(t *testing.T) {
file, invalid, _ := prepareFiles(t) file, invalid, _, dir := prepareFiles(t)
defer os.RemoveAll(dir)
statFile, err := Lstat(file) statFile, err := Lstat(file)
if err != nil { if err != nil {

View File

@ -1,12 +1,14 @@
package system package system
import ( import (
"os"
"syscall" "syscall"
"testing" "testing"
) )
func TestFromStatT(t *testing.T) { func TestFromStatT(t *testing.T) {
file, _, _ := prepareFiles(t) file, _, _, dir := prepareFiles(t)
defer os.RemoveAll(dir)
stat := &syscall.Stat_t{} stat := &syscall.Stat_t{}
err := syscall.Lstat(file, stat) err := syscall.Lstat(file, stat)

View File

@ -8,7 +8,7 @@ import (
"testing" "testing"
) )
func prepareFiles(t *testing.T) (string, string, string) { func prepareFiles(t *testing.T) (string, string, string, string) {
dir, err := ioutil.TempDir("", "docker-system-test") dir, err := ioutil.TempDir("", "docker-system-test")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -26,11 +26,12 @@ func prepareFiles(t *testing.T) (string, string, string) {
t.Fatal(err) t.Fatal(err)
} }
return file, invalid, symlink return file, invalid, symlink, dir
} }
func TestLUtimesNano(t *testing.T) { func TestLUtimesNano(t *testing.T) {
file, invalid, symlink := prepareFiles(t) file, invalid, symlink, dir := prepareFiles(t)
defer os.RemoveAll(dir)
before, err := os.Stat(file) before, err := os.Stat(file)
if err != nil { if err != nil {