mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
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:
committed by
Ramkumar Chinchani
parent
4be2652085
commit
0d77b60de7
+2
-11
@@ -398,12 +398,7 @@ func TestScrub(t *testing.T) {
|
||||
config.HTTP.Port = port
|
||||
controller := api.NewController(config)
|
||||
|
||||
dir, err := ioutil.TempDir("", "scrub-test")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
defer os.RemoveAll(dir)
|
||||
dir := t.TempDir()
|
||||
|
||||
controller.Config.Storage.RootDirectory = dir
|
||||
go func(controller *api.Controller) {
|
||||
@@ -480,11 +475,7 @@ func TestScrub(t *testing.T) {
|
||||
Convey("bad index.json", func(c C) {
|
||||
port := GetFreePort()
|
||||
|
||||
dir, err := ioutil.TempDir("", "scrub-test")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
dir := t.TempDir()
|
||||
|
||||
repoName := "badIndex"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user