test: use T.TempDir to create temporary test directory
The directory created by `T.TempDir` is automatically removed when the test and all its subtests complete. Reference: https://pkg.go.dev/testing#T.TempDir Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
parent
c9a08da29f
commit
00ea3eb285
12 changed files with 104 additions and 392 deletions
|
|
@ -1,8 +1,6 @@
|
|||
package fsjobqueue_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
|
@ -14,16 +12,12 @@ import (
|
|||
|
||||
func TestJobQueueInterface(t *testing.T) {
|
||||
jobqueuetest.TestJobQueue(t, func() (jobqueue.JobQueue, func(), error) {
|
||||
dir, err := ioutil.TempDir("", "jobqueue-test-")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
dir := t.TempDir()
|
||||
q, err := fsjobqueue.New(dir)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
stop := func() {
|
||||
_ = os.RemoveAll(dir)
|
||||
}
|
||||
return q, stop, nil
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue