aboutsummaryrefslogtreecommitdiff
path: root/db_test.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-05-28 10:28:15 -0600
committerBen Johnson <benbjohnson@yahoo.com>2014-05-28 10:31:22 -0600
commitb7896919761d1f942a042603510b30921a8c2009 (patch)
treead956b5e92c9e371df3f10277126b6c5821ecd2e /db_test.go
parentMerge pull request #175 from benbjohnson/check-loop (diff)
downloaddedo-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.go15
1 files changed, 4 insertions, 11 deletions
diff --git a/db_test.go b/db_test.go
index 06accd3..e1c4aaa 100644
--- a/db_test.go
+++ b/db_test.go
@@ -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)
}
}