mirror of
https://github.com/restic/restic.git
synced 2025-08-13 07:57:40 +00:00
test: Use testing.T.Cleanup to remove tempdirs
This commit is contained in:
@@ -101,9 +101,8 @@ func newRandomCredentials(t testing.TB) (key, secret string) {
|
||||
type MinioTestConfig struct {
|
||||
s3.Config
|
||||
|
||||
tempdir string
|
||||
removeTempdir func()
|
||||
stopServer func()
|
||||
tempdir string
|
||||
stopServer func()
|
||||
}
|
||||
|
||||
func createS3(t testing.TB, cfg MinioTestConfig, tr http.RoundTripper) (be restic.Backend, err error) {
|
||||
@@ -132,7 +131,7 @@ func newMinioTestSuite(ctx context.Context, t testing.TB) *test.Suite {
|
||||
NewConfig: func() (interface{}, error) {
|
||||
cfg := MinioTestConfig{}
|
||||
|
||||
cfg.tempdir, cfg.removeTempdir = rtest.TempDir(t)
|
||||
cfg.tempdir = rtest.TempDir(t)
|
||||
key, secret := newRandomCredentials(t)
|
||||
cfg.stopServer = runMinio(ctx, t, cfg.tempdir, key, secret)
|
||||
|
||||
@@ -179,9 +178,6 @@ func newMinioTestSuite(ctx context.Context, t testing.TB) *test.Suite {
|
||||
if cfg.stopServer != nil {
|
||||
cfg.stopServer()
|
||||
}
|
||||
if cfg.removeTempdir != nil {
|
||||
cfg.removeTempdir()
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user