libs/cmn: Remove Tempfile, Tempdir, switch to ioutil variants (#2114)

Our Tempfile was just a wrapper on ioutil that panicked instead of error.

Our Tempdir was a less safe variant of ioutil's Tempdir.
This commit is contained in:
ValarDragon
2018-07-30 16:19:33 -07:00
committed by Alexander Simmerl
parent be642754f5
commit a83eed104c
7 changed files with 38 additions and 47 deletions

View File

@ -2,6 +2,7 @@ package db
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
@ -17,8 +18,8 @@ func cleanupDBDir(dir, name string) {
func testBackendGetSetDelete(t *testing.T, backend DBBackendType) {
// Default
dir, dirname := cmn.Tempdir(fmt.Sprintf("test_backend_%s_", backend))
defer dir.Close()
dirname, err := ioutil.TempDir("", fmt.Sprintf("test_backend_%s_", backend))
require.Nil(t, err)
db := NewDB("testdb", backend, dirname)
// A nonexistent key should return nil, even if the key is empty