Skip to content

Commit

Permalink
Add all journal modes as constants (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
markuswustenberg authored Feb 17, 2023
1 parent 1c621ec commit f7232a2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ import (
type JournalMode string

const (
JournalModeWAL = "wal"
JournalModeDelete = JournalMode("delete")
JournalModeTruncate = JournalMode("truncate")
JournalModePersist = JournalMode("persist")
JournalModeMemory = JournalMode("memory")
JournalModeWAL = JournalMode("wal")
JournalModeOff = JournalMode("off")
)

func (j JournalMode) String() string {
Expand Down
11 changes: 11 additions & 0 deletions sqlite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ func TestDB_Open(t *testing.T) {
})
}
})

t.Run("can set different journal mode", func(t *testing.T) {
db := open(t, sqlite.Options{
JournalMode: sqlite.JournalModeTruncate,
})

var actual string
err := db.QueryRow(`pragma journal_mode`).Scan(&actual)
assert.NoErr(t, err)
assert.Equal(t, sqlite.JournalModeTruncate.String(), actual)
})
}

func TestDB_QueryRow(t *testing.T) {
Expand Down

0 comments on commit f7232a2

Please sign in to comment.