backend/tests: Print error stacktrace if available

This commit is contained in:
Alexander Neumann 2017-04-10 21:46:41 +02:00
parent 27ce6a85e9
commit 698ba57597
1 changed files with 21 additions and 21 deletions

View File

@ -43,7 +43,7 @@ func open(t testing.TB) restic.Backend {
if !butInitialized { if !butInitialized {
be, err := CreateFn() be, err := CreateFn()
if err != nil { if err != nil {
t.Fatalf("Create returned unexpected error: %v", err) t.Fatalf("Create returned unexpected error: %+v", err)
} }
but = be but = be
@ -54,7 +54,7 @@ func open(t testing.TB) restic.Backend {
var err error var err error
but, err = OpenFn() but, err = OpenFn()
if err != nil { if err != nil {
t.Fatalf("Open returned unexpected error: %v", err) t.Fatalf("Open returned unexpected error: %+v", err)
} }
} }
@ -68,7 +68,7 @@ func close(t testing.TB) {
err := but.Close() err := but.Close()
if err != nil { if err != nil {
t.Fatalf("Close returned unexpected error: %v", err) t.Fatalf("Close returned unexpected error: %+v", err)
} }
but = nil but = nil
@ -82,14 +82,14 @@ func TestCreate(t testing.TB) {
be, err := CreateFn() be, err := CreateFn()
if err != nil { if err != nil {
t.Fatalf("Create returned error: %v", err) t.Fatalf("Create returned error: %+v", err)
} }
butInitialized = true butInitialized = true
err = be.Close() err = be.Close()
if err != nil { if err != nil {
t.Fatalf("Close returned error: %v", err) t.Fatalf("Close returned error: %+v", err)
} }
} }
@ -101,12 +101,12 @@ func TestOpen(t testing.TB) {
be, err := OpenFn() be, err := OpenFn()
if err != nil { if err != nil {
t.Fatalf("Open returned error: %v", err) t.Fatalf("Open returned error: %+v", err)
} }
err = be.Close() err = be.Close()
if err != nil { if err != nil {
t.Fatalf("Close returned error: %v", err) t.Fatalf("Close returned error: %+v", err)
} }
} }
@ -132,7 +132,7 @@ func TestCreateWithConfig(t testing.TB) {
// remove config // remove config
err = b.Remove(restic.Handle{Type: restic.ConfigFile, Name: ""}) err = b.Remove(restic.Handle{Type: restic.ConfigFile, Name: ""})
if err != nil { if err != nil {
t.Fatalf("unexpected error removing config: %v", err) t.Fatalf("unexpected error removing config: %+v", err)
} }
} }
@ -162,7 +162,7 @@ func TestConfig(t testing.TB) {
err = b.Save(restic.Handle{Type: restic.ConfigFile}, strings.NewReader(testString)) err = b.Save(restic.Handle{Type: restic.ConfigFile}, strings.NewReader(testString))
if err != nil { if err != nil {
t.Fatalf("Save() error: %v", err) t.Fatalf("Save() error: %+v", err)
} }
// try accessing the config with different names, should all return the // try accessing the config with different names, should all return the
@ -171,7 +171,7 @@ func TestConfig(t testing.TB) {
h := restic.Handle{Type: restic.ConfigFile, Name: name} h := restic.Handle{Type: restic.ConfigFile, Name: name}
buf, err := backend.LoadAll(b, h) buf, err := backend.LoadAll(b, h)
if err != nil { if err != nil {
t.Fatalf("unable to read config with name %q: %v", name, err) t.Fatalf("unable to read config with name %q: %+v", name, err)
} }
if string(buf) != testString { if string(buf) != testString {
@ -203,7 +203,7 @@ func TestLoad(t testing.TB) {
handle := restic.Handle{Type: restic.DataFile, Name: id.String()} handle := restic.Handle{Type: restic.DataFile, Name: id.String()}
err = b.Save(handle, bytes.NewReader(data)) err = b.Save(handle, bytes.NewReader(data))
if err != nil { if err != nil {
t.Fatalf("Save() error: %v", err) t.Fatalf("Save() error: %+v", err)
} }
rd, err := b.Load(handle, 100, -1) rd, err := b.Load(handle, 100, -1)
@ -238,13 +238,13 @@ func TestLoad(t testing.TB) {
rd, err := b.Load(handle, getlen, int64(o)) rd, err := b.Load(handle, getlen, int64(o))
if err != nil { if err != nil {
t.Errorf("Load(%d, %d) returned unexpected error: %v", l, o, err) t.Errorf("Load(%d, %d) returned unexpected error: %+v", l, o, err)
continue continue
} }
buf, err := ioutil.ReadAll(rd) buf, err := ioutil.ReadAll(rd)
if err != nil { if err != nil {
t.Errorf("Load(%d, %d) ReadAll() returned unexpected error: %v", l, o, err) t.Errorf("Load(%d, %d) ReadAll() returned unexpected error: %+v", l, o, err)
rd.Close() rd.Close()
continue continue
} }
@ -269,7 +269,7 @@ func TestLoad(t testing.TB) {
err = rd.Close() err = rd.Close()
if err != nil { if err != nil {
t.Errorf("Load(%d, %d) rd.Close() returned unexpected error: %v", l, o, err) t.Errorf("Load(%d, %d) rd.Close() returned unexpected error: %+v", l, o, err)
continue continue
} }
} }
@ -325,7 +325,7 @@ func TestSave(t testing.TB) {
err = b.Remove(h) err = b.Remove(h)
if err != nil { if err != nil {
t.Fatalf("error removing item: %v", err) t.Fatalf("error removing item: %+v", err)
} }
} }
@ -366,7 +366,7 @@ func TestSave(t testing.TB) {
err = b.Remove(h) err = b.Remove(h)
if err != nil { if err != nil {
t.Fatalf("error removing item: %v", err) t.Fatalf("error removing item: %+v", err)
} }
} }
@ -391,13 +391,13 @@ func TestSaveFilenames(t testing.TB) {
h := restic.Handle{Name: test.name, Type: restic.DataFile} h := restic.Handle{Name: test.name, Type: restic.DataFile}
err := b.Save(h, strings.NewReader(test.data)) err := b.Save(h, strings.NewReader(test.data))
if err != nil { if err != nil {
t.Errorf("test %d failed: Save() returned %v", i, err) t.Errorf("test %d failed: Save() returned %+v", i, err)
continue continue
} }
buf, err := backend.LoadAll(b, h) buf, err := backend.LoadAll(b, h)
if err != nil { if err != nil {
t.Errorf("test %d failed: Load() returned %v", i, err) t.Errorf("test %d failed: Load() returned %+v", i, err)
continue continue
} }
@ -407,7 +407,7 @@ func TestSaveFilenames(t testing.TB) {
err = b.Remove(h) err = b.Remove(h)
if err != nil { if err != nil {
t.Errorf("test %d failed: Remove() returned %v", i, err) t.Errorf("test %d failed: Remove() returned %+v", i, err)
continue continue
} }
} }
@ -576,7 +576,7 @@ func TestDelete(t testing.TB) {
err := be.Delete() err := be.Delete()
if err != nil { if err != nil {
t.Fatalf("error deleting backend: %v", err) t.Fatalf("error deleting backend: %+v", err)
} }
} }
@ -594,6 +594,6 @@ func TestCleanup(t testing.TB) {
err := CleanupFn() err := CleanupFn()
if err != nil { if err != nil {
t.Fatalf("Cleanup returned error: %v", err) t.Fatalf("Cleanup returned error: %+v", err)
} }
} }