mirror of
https://github.com/golang/go
synced 2024-11-02 13:42:29 +00:00
net/http: replace os.MkdirTemp with T.TempDir
Updates: #45402 Change-Id: Ia61f422d058bf57fc3688abc25597d6cc1692c51 Reviewed-on: https://go-review.googlesource.com/c/go/+/307653 Run-TryBot: Dave Cheney <dave@cheney.net> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dave Cheney <dave@cheney.net> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
This commit is contained in:
parent
4bbe046aad
commit
5d5f779db4
2 changed files with 3 additions and 9 deletions
|
@ -23,12 +23,10 @@ func checker(t *testing.T) func(string, error) {
|
|||
func TestFileTransport(t *testing.T) {
|
||||
check := checker(t)
|
||||
|
||||
dname, err := os.MkdirTemp("", "")
|
||||
check("TempDir", err)
|
||||
dname := t.TempDir()
|
||||
fname := filepath.Join(dname, "foo.txt")
|
||||
err = os.WriteFile(fname, []byte("Bar"), 0644)
|
||||
err := os.WriteFile(fname, []byte("Bar"), 0644)
|
||||
check("WriteFile", err)
|
||||
defer os.Remove(dname)
|
||||
defer os.Remove(fname)
|
||||
|
||||
tr := &Transport{}
|
||||
|
|
|
@ -378,11 +378,7 @@ func mustRemoveAll(dir string) {
|
|||
|
||||
func TestFileServerImplicitLeadingSlash(t *testing.T) {
|
||||
defer afterTest(t)
|
||||
tempDir, err := os.MkdirTemp("", "")
|
||||
if err != nil {
|
||||
t.Fatalf("TempDir: %v", err)
|
||||
}
|
||||
defer mustRemoveAll(tempDir)
|
||||
tempDir := t.TempDir()
|
||||
if err := os.WriteFile(filepath.Join(tempDir, "foo.txt"), []byte("Hello world"), 0644); err != nil {
|
||||
t.Fatalf("WriteFile: %v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue