mirror of https://github.com/status-im/consul.git
testutil: If testing.T is nil panic with error (#4725)
This commit is contained in:
parent
7742aec226
commit
0934940f4e
|
@ -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…
Reference in New Issue