Browse Source

testutil: If testing.T is nil panic with error (#4725)

pull/4860/head
James Hartig 6 years ago committed by Jack Pearkes
parent
commit
0934940f4e
  1. 6
      testutil/io.go

6
testutil/io.go

@ -39,6 +39,9 @@ func TempDir(t *testing.T, name string) string {
name = strings.Replace(name, "/", "_", -1)
d, err := ioutil.TempDir(tmpdir, name)
if err != nil {
if t == nil {
panic(err)
}
t.Fatalf("err: %s", err)
}
return d
@ -55,6 +58,9 @@ func TempFile(t *testing.T, name string) *os.File {
}
f, err := ioutil.TempFile(tmpdir, name)
if err != nil {
if t == nil {
panic(err)
}
t.Fatalf("err: %s", err)
}
return f

Loading…
Cancel
Save