Don't forget to clenaup tmpdir in TestFileSpecPlugin()

Also remove redundant code.

Signed-off-by: Zefan Li <lizefan@huawei.com>
This commit is contained in:
Zefan Li 2015-06-04 13:21:28 +08:00
parent 58c924d2cd
commit 2f287cc873

View file

@ -5,7 +5,6 @@ import (
"io/ioutil" "io/ioutil"
"net" "net"
"os" "os"
"path"
"path/filepath" "path/filepath"
"reflect" "reflect"
"testing" "testing"
@ -66,6 +65,7 @@ func TestFileSpecPlugin(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
defer os.RemoveAll(tmpdir)
cases := []struct { cases := []struct {
path string path string
@ -79,9 +79,6 @@ func TestFileSpecPlugin(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
if err = os.MkdirAll(path.Dir(c.path), 0755); err != nil {
t.Fatal(err)
}
if err = ioutil.WriteFile(c.path, []byte(c.addr), 0644); err != nil { if err = ioutil.WriteFile(c.path, []byte(c.addr), 0644); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -103,6 +100,5 @@ func TestFileSpecPlugin(t *testing.T) {
if p.Addr != c.addr { if p.Addr != c.addr {
t.Fatalf("Expected plugin addr `%s`, got %s\n", c.addr, p.Addr) t.Fatalf("Expected plugin addr `%s`, got %s\n", c.addr, p.Addr)
} }
os.Remove(c.path)
} }
} }