mirror of
https://github.com/restic/restic.git
synced 2025-12-04 00:21:46 +00:00
Add test for to prevent double create
This commit is contained in:
@@ -7,13 +7,14 @@ import (
|
||||
"github.com/restic/restic/backend/test"
|
||||
)
|
||||
|
||||
func TestTestBackendCreate(t *testing.T) { test.Create(t) }
|
||||
func TestTestBackendOpen(t *testing.T) { test.Open(t) }
|
||||
func TestTestBackendLocation(t *testing.T) { test.Location(t) }
|
||||
func TestTestBackendConfig(t *testing.T) { test.Config(t) }
|
||||
func TestTestBackendGetReader(t *testing.T) { test.GetReader(t) }
|
||||
func TestTestBackendLoad(t *testing.T) { test.Load(t) }
|
||||
func TestTestBackendWrite(t *testing.T) { test.Write(t) }
|
||||
func TestTestBackendGeneric(t *testing.T) { test.Generic(t) }
|
||||
func TestTestBackendDelete(t *testing.T) { test.Delete(t) }
|
||||
func TestTestBackendCleanup(t *testing.T) { test.Cleanup(t) }
|
||||
func TestTestBackendCreate(t *testing.T) { test.Create(t) }
|
||||
func TestTestBackendOpen(t *testing.T) { test.Open(t) }
|
||||
func TestTestBackendCreateWithConfig(t *testing.T) { test.CreateWithConfig(t) }
|
||||
func TestTestBackendLocation(t *testing.T) { test.Location(t) }
|
||||
func TestTestBackendConfig(t *testing.T) { test.Config(t) }
|
||||
func TestTestBackendGetReader(t *testing.T) { test.GetReader(t) }
|
||||
func TestTestBackendLoad(t *testing.T) { test.Load(t) }
|
||||
func TestTestBackendWrite(t *testing.T) { test.Write(t) }
|
||||
func TestTestBackendGeneric(t *testing.T) { test.Generic(t) }
|
||||
func TestTestBackendDelete(t *testing.T) { test.Delete(t) }
|
||||
func TestTestBackendCleanup(t *testing.T) { test.Cleanup(t) }
|
||||
|
||||
@@ -107,6 +107,32 @@ func Open(t testing.TB) {
|
||||
}
|
||||
}
|
||||
|
||||
// CreateWithConfig tests that creating a backend in a location which already
|
||||
// has a config file fails.
|
||||
func CreateWithConfig(t testing.TB) {
|
||||
if CreateFn == nil {
|
||||
t.Fatalf("CreateFn not set")
|
||||
}
|
||||
|
||||
b := open(t)
|
||||
defer close(t)
|
||||
|
||||
// save a config
|
||||
store(t, b, backend.Config, []byte("test config"))
|
||||
|
||||
// now create the backend again, this must fail
|
||||
_, err := CreateFn()
|
||||
if err == nil {
|
||||
t.Fatalf("expected error not found for creating a backend with an existing config file")
|
||||
}
|
||||
|
||||
// remove config
|
||||
err = b.Remove(backend.Config, "")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error removing config: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Location tests that a location string is returned.
|
||||
func Location(t testing.TB) {
|
||||
b := open(t)
|
||||
|
||||
Reference in New Issue
Block a user