소스 검색

Don't forget to clenaup tmpdir in TestFileSpecPlugin()

Also remove redundant code.

Signed-off-by: Zefan Li <lizefan@huawei.com>
Zefan Li 10 년 전
부모
커밋
d31224743b
1개의 변경된 파일1개의 추가작업 그리고 5개의 파일을 삭제
  1. 1 5
      pkg/plugins/discovery_test.go

+ 1 - 5
pkg/plugins/discovery_test.go

@@ -5,7 +5,6 @@ import (
 	"io/ioutil"
 	"net"
 	"os"
-	"path"
 	"path/filepath"
 	"reflect"
 	"testing"
@@ -66,6 +65,7 @@ func TestFileSpecPlugin(t *testing.T) {
 	if err != nil {
 		t.Fatal(err)
 	}
+	defer os.RemoveAll(tmpdir)
 
 	cases := []struct {
 		path string
@@ -79,9 +79,6 @@ func TestFileSpecPlugin(t *testing.T) {
 	}
 
 	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 {
 			t.Fatal(err)
 		}
@@ -103,6 +100,5 @@ func TestFileSpecPlugin(t *testing.T) {
 		if p.Addr != c.addr {
 			t.Fatalf("Expected plugin addr `%s`, got %s\n", c.addr, p.Addr)
 		}
-		os.Remove(c.path)
 	}
 }