diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-05-28 10:28:15 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-05-28 10:31:22 -0600 |
commit | b7896919761d1f942a042603510b30921a8c2009 (patch) | |
tree | ad956b5e92c9e371df3f10277126b6c5821ecd2e /db_test.go | |
parent | Merge pull request #175 from benbjohnson/check-loop (diff) | |
download | dedo-b7896919761d1f942a042603510b30921a8c2009.tar.gz dedo-b7896919761d1f942a042603510b30921a8c2009.tar.xz |
Add streaming check.
This commit changes Tx.Check() to return a channel through which check errors are returned. This allows
errors to be found before checking the entire data file.
Diffstat (limited to 'db_test.go')
-rw-r--r-- | db_test.go | 15 |
1 files changed, 4 insertions, 11 deletions
@@ -53,12 +53,12 @@ func TestOpen_Check(t *testing.T) { withTempPath(func(path string) { db, err := Open(path, 0666) assert.NoError(t, err) - assert.NoError(t, db.View(func(tx *Tx) error { return tx.Check() })) + assert.NoError(t, db.View(func(tx *Tx) error { return <-tx.Check() })) db.Close() db, err = Open(path, 0666) assert.NoError(t, err) - assert.NoError(t, db.View(func(tx *Tx) error { return tx.Check() })) + assert.NoError(t, db.View(func(tx *Tx) error { return <-tx.Check() })) db.Close() }) } @@ -464,20 +464,13 @@ func withOpenDB(fn func(*DB, string)) { // mustCheck runs a consistency check on the database and panics if any errors are found. func mustCheck(db *DB) { err := db.Update(func(tx *Tx) error { - return tx.Check() + return <-tx.Check() }) if err != nil { // Copy db off first. var path = tempfile() db.View(func(tx *Tx) error { return tx.CopyFile(path, 0600) }) - - if errors, ok := err.(ErrorList); ok { - for _, err := range errors { - warn(err) - } - } - warn(err) - panic("check failure: " + path) + panic("check failure: " + err.Error() + ": " + path) } } |