mirror of
https://github.com/golang/go
synced 2024-11-22 05:04:40 -07:00
net/http: make test remove temporary file and directory
R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5486044
This commit is contained in:
parent
a620f2b73a
commit
68ec347c16
@ -7,6 +7,7 @@ package http_test
|
|||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@ -28,6 +29,8 @@ func TestFileTransport(t *testing.T) {
|
|||||||
fname := filepath.Join(dname, "foo.txt")
|
fname := filepath.Join(dname, "foo.txt")
|
||||||
err = ioutil.WriteFile(fname, []byte("Bar"), 0644)
|
err = ioutil.WriteFile(fname, []byte("Bar"), 0644)
|
||||||
check("WriteFile", err)
|
check("WriteFile", err)
|
||||||
|
defer os.Remove(dname)
|
||||||
|
defer os.Remove(fname)
|
||||||
|
|
||||||
tr := &http.Transport{}
|
tr := &http.Transport{}
|
||||||
tr.RegisterProtocol("file", http.NewFileTransport(http.Dir(dname)))
|
tr.RegisterProtocol("file", http.NewFileTransport(http.Dir(dname)))
|
||||||
|
Loading…
Reference in New Issue
Block a user