mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 02:48:55 +00:00
Fix linter warnings
This commit is contained in:
parent
50e0d5e6b5
commit
b5511e8e4c
@ -17,7 +17,7 @@ import (
|
||||
rtest "github.com/restic/restic/internal/test"
|
||||
)
|
||||
|
||||
func newAzureTestSuite(t testing.TB) *test.Suite[azure.Config] {
|
||||
func newAzureTestSuite() *test.Suite[azure.Config] {
|
||||
return &test.Suite[azure.Config]{
|
||||
// do not use excessive data
|
||||
MinimalData: true,
|
||||
@ -59,7 +59,7 @@ func TestBackendAzure(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Logf("run tests")
|
||||
newAzureTestSuite(t).RunTests(t)
|
||||
newAzureTestSuite().RunTests(t)
|
||||
}
|
||||
|
||||
func BenchmarkBackendAzure(t *testing.B) {
|
||||
@ -77,7 +77,7 @@ func BenchmarkBackendAzure(t *testing.B) {
|
||||
}
|
||||
|
||||
t.Logf("run tests")
|
||||
newAzureTestSuite(t).RunBenchmarks(t)
|
||||
newAzureTestSuite().RunBenchmarks(t)
|
||||
}
|
||||
|
||||
func TestUploadLargeFile(t *testing.T) {
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
rtest "github.com/restic/restic/internal/test"
|
||||
)
|
||||
|
||||
func newB2TestSuite(t testing.TB) *test.Suite[b2.Config] {
|
||||
func newB2TestSuite() *test.Suite[b2.Config] {
|
||||
return &test.Suite[b2.Config]{
|
||||
// do not use excessive data
|
||||
MinimalData: true,
|
||||
@ -59,10 +59,10 @@ func TestBackendB2(t *testing.T) {
|
||||
}()
|
||||
|
||||
testVars(t)
|
||||
newB2TestSuite(t).RunTests(t)
|
||||
newB2TestSuite().RunTests(t)
|
||||
}
|
||||
|
||||
func BenchmarkBackendb2(t *testing.B) {
|
||||
testVars(t)
|
||||
newB2TestSuite(t).RunBenchmarks(t)
|
||||
newB2TestSuite().RunBenchmarks(t)
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
rtest "github.com/restic/restic/internal/test"
|
||||
)
|
||||
|
||||
func newGSTestSuite(t testing.TB) *test.Suite[gs.Config] {
|
||||
func newGSTestSuite() *test.Suite[gs.Config] {
|
||||
return &test.Suite[gs.Config]{
|
||||
// do not use excessive data
|
||||
MinimalData: true,
|
||||
@ -56,7 +56,7 @@ func TestBackendGS(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Logf("run tests")
|
||||
newGSTestSuite(t).RunTests(t)
|
||||
newGSTestSuite().RunTests(t)
|
||||
}
|
||||
|
||||
func BenchmarkBackendGS(t *testing.B) {
|
||||
@ -77,5 +77,5 @@ func BenchmarkBackendGS(t *testing.B) {
|
||||
}
|
||||
|
||||
t.Logf("run tests")
|
||||
newGSTestSuite(t).RunBenchmarks(t)
|
||||
newGSTestSuite().RunBenchmarks(t)
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ func runRESTServer(ctx context.Context, t testing.TB, dir string) (*url.URL, fun
|
||||
return url, cleanup
|
||||
}
|
||||
|
||||
func newTestSuite(_ context.Context, t testing.TB, url *url.URL, minimalData bool) *test.Suite[rest.Config] {
|
||||
func newTestSuite(url *url.URL, minimalData bool) *test.Suite[rest.Config] {
|
||||
return &test.Suite[rest.Config]{
|
||||
MinimalData: minimalData,
|
||||
|
||||
@ -94,7 +94,7 @@ func TestBackendREST(t *testing.T) {
|
||||
serverURL, cleanup := runRESTServer(ctx, t, dir)
|
||||
defer cleanup()
|
||||
|
||||
newTestSuite(ctx, t, serverURL, false).RunTests(t)
|
||||
newTestSuite(serverURL, false).RunTests(t)
|
||||
}
|
||||
|
||||
func TestBackendRESTExternalServer(t *testing.T) {
|
||||
@ -108,10 +108,7 @@ func TestBackendRESTExternalServer(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
newTestSuite(ctx, t, cfg.URL, true).RunTests(t)
|
||||
newTestSuite(cfg.URL, true).RunTests(t)
|
||||
}
|
||||
|
||||
func BenchmarkBackendREST(t *testing.B) {
|
||||
@ -122,5 +119,5 @@ func BenchmarkBackendREST(t *testing.B) {
|
||||
serverURL, cleanup := runRESTServer(ctx, t, dir)
|
||||
defer cleanup()
|
||||
|
||||
newTestSuite(ctx, t, serverURL, false).RunBenchmarks(t)
|
||||
newTestSuite(serverURL, false).RunBenchmarks(t)
|
||||
}
|
||||
|
@ -94,35 +94,31 @@ func newRandomCredentials(t testing.TB) (key, secret string) {
|
||||
return key, secret
|
||||
}
|
||||
|
||||
func newMinioTestSuite(ctx context.Context, t testing.TB, key string, secret string) *test.Suite[s3.Config] {
|
||||
return &test.Suite[s3.Config]{
|
||||
// NewConfig returns a config for a new temporary backend that will be used in tests.
|
||||
NewConfig: func() (*s3.Config, error) {
|
||||
cfg := s3.NewConfig()
|
||||
cfg.Endpoint = "localhost:9000"
|
||||
cfg.Bucket = "restictestbucket"
|
||||
cfg.Prefix = fmt.Sprintf("test-%d", time.Now().UnixNano())
|
||||
cfg.UseHTTP = true
|
||||
cfg.KeyID = key
|
||||
cfg.Secret = options.NewSecretString(secret)
|
||||
return &cfg, nil
|
||||
},
|
||||
|
||||
Factory: s3.NewFactory(),
|
||||
}
|
||||
}
|
||||
|
||||
func createMinioTestSuite(t testing.TB) (*test.Suite[s3.Config], func()) {
|
||||
func newMinioTestSuite(t testing.TB) (*test.Suite[s3.Config], func()) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
tempdir := rtest.TempDir(t)
|
||||
key, secret := newRandomCredentials(t)
|
||||
cleanup := runMinio(ctx, t, tempdir, key, secret)
|
||||
|
||||
return newMinioTestSuite(ctx, t, key, secret), func() {
|
||||
defer cancel()
|
||||
defer cleanup()
|
||||
}
|
||||
return &test.Suite[s3.Config]{
|
||||
// NewConfig returns a config for a new temporary backend that will be used in tests.
|
||||
NewConfig: func() (*s3.Config, error) {
|
||||
cfg := s3.NewConfig()
|
||||
cfg.Endpoint = "localhost:9000"
|
||||
cfg.Bucket = "restictestbucket"
|
||||
cfg.Prefix = fmt.Sprintf("test-%d", time.Now().UnixNano())
|
||||
cfg.UseHTTP = true
|
||||
cfg.KeyID = key
|
||||
cfg.Secret = options.NewSecretString(secret)
|
||||
return &cfg, nil
|
||||
},
|
||||
|
||||
Factory: s3.NewFactory(),
|
||||
}, func() {
|
||||
defer cancel()
|
||||
defer cleanup()
|
||||
}
|
||||
}
|
||||
|
||||
func TestBackendMinio(t *testing.T) {
|
||||
@ -139,7 +135,7 @@ func TestBackendMinio(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
suite, cleanup := createMinioTestSuite(t)
|
||||
suite, cleanup := newMinioTestSuite(t)
|
||||
defer cleanup()
|
||||
|
||||
suite.RunTests(t)
|
||||
@ -153,13 +149,13 @@ func BenchmarkBackendMinio(t *testing.B) {
|
||||
return
|
||||
}
|
||||
|
||||
suite, cleanup := createMinioTestSuite(t)
|
||||
suite, cleanup := newMinioTestSuite(t)
|
||||
defer cleanup()
|
||||
|
||||
suite.RunBenchmarks(t)
|
||||
}
|
||||
|
||||
func newS3TestSuite(t testing.TB) *test.Suite[s3.Config] {
|
||||
func newS3TestSuite() *test.Suite[s3.Config] {
|
||||
return &test.Suite[s3.Config]{
|
||||
// do not use excessive data
|
||||
MinimalData: true,
|
||||
@ -202,7 +198,7 @@ func TestBackendS3(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Logf("run tests")
|
||||
newS3TestSuite(t).RunTests(t)
|
||||
newS3TestSuite().RunTests(t)
|
||||
}
|
||||
|
||||
func BenchmarkBackendS3(t *testing.B) {
|
||||
@ -220,5 +216,5 @@ func BenchmarkBackendS3(t *testing.B) {
|
||||
}
|
||||
|
||||
t.Logf("run tests")
|
||||
newS3TestSuite(t).RunBenchmarks(t)
|
||||
newS3TestSuite().RunBenchmarks(t)
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ func beTest(ctx context.Context, be restic.Backend, h restic.Handle) (bool, erro
|
||||
|
||||
// TestStripPasswordCall tests that the StripPassword method of a factory can be called without crashing.
|
||||
// It does not verify whether passwords are removed correctly
|
||||
func (s *Suite[C]) TestStripPasswordCall(t *testing.T) {
|
||||
func (s *Suite[C]) TestStripPasswordCall(_ *testing.T) {
|
||||
s.Factory.StripPassword("some random string")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user