-
Notifications
You must be signed in to change notification settings - Fork 649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add db test in read-only mode #46
Conversation
Codecov Report
@@ Coverage Diff @@
## master #46 +/- ##
=========================================
Coverage ? 85.56%
=========================================
Files ? 9
Lines ? 1857
Branches ? 0
=========================================
Hits ? 1589
Misses ? 159
Partials ? 109
Continue to review full report at Codecov.
|
This pr tests read-only mode db, which should increase test coverage, like this line https://codecov.io/gh/coreos/bbolt/src/master/db.go#L179 Confused about the codecov report:sweat: |
o := &bolt.Options{ReadOnly: true} | ||
readOnlyDB, err := bolt.Open(f, 0666, o) | ||
if err != nil { | ||
panic(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.Fatal(err)
db_test.go
Outdated
} | ||
return nil | ||
}); err != nil { | ||
log.Fatal(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.Fatal(err)
db_test.go
Outdated
} | ||
|
||
if err := readOnlyDB.Close(); err != nil { | ||
log.Fatal(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.Fatal(err)
db_test.go
Outdated
@@ -1125,6 +1125,61 @@ func TestDB_BatchTime(t *testing.T) { | |||
} | |||
} | |||
|
|||
// Ensure that a database in read only mode can read from read-only transaction, | |||
// but can't launch read-write transaction. | |||
func TestDB_ReadOnlyMode(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TestDB_Open_ReadOnly
to match TestDB_Open_InitialMmapSize
@@ -1449,15 +1504,7 @@ type DB struct { | |||
|
|||
// MustOpenDB returns a new, open DB at a temporary location. | |||
func MustOpenDB() *DB { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
squash commit
db_test.go
Outdated
}); err != nil { | ||
t.Fatal(err) | ||
} | ||
err := db.DB.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if err := db.DB.Close(); err != nil {
to match other if's
db_test.go
Outdated
@@ -1125,6 +1125,61 @@ func TestDB_BatchTime(t *testing.T) { | |||
} | |||
} | |||
|
|||
// Ensure that a database in read only mode can read from read-only transaction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use godoc style:
TestDB_Open_ReadOnly checks a database in read only mode can read but not write.
fd83221
to
dd0d109
Compare
dd0d109
to
d294ec8
Compare
I have updated commit and moved |
@lorneli why this is closed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm thanks
@lorneli is this OK to merge? |
@heyitsanthony I believe he accidentally closed the PR when commenting. we can just merge this in. |
@heyitsanthony @xiang90 I accidentally closed this PR when commenting on mobile phone. Its screen is too small.... Thank you for your review. |
No description provided.