Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gosqlite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gosqlite
Commits
ffc9c2cd
Commit
ffc9c2cd
authored
Mar 04, 2012
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test Backup misuse.
parent
e0cd2ca4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
backup.go
backup.go
+6
-0
backup_test.go
backup_test.go
+17
-0
No files found.
backup.go
View file @
ffc9c2cd
...
...
@@ -53,6 +53,9 @@ type Backup struct {
// Copy up to N pages between the source and destination databases
// (See http://sqlite.org/c3ref/backup_finish.html#sqlite3backupstep)
func
(
b
*
Backup
)
Step
(
npage
int
)
error
{
if
b
==
nil
{
return
ErrMisuse
}
rv
:=
C
.
sqlite3_backup_step
(
b
.
sb
,
C
.
int
(
npage
))
if
rv
==
C
.
SQLITE_OK
||
Errno
(
rv
)
==
ErrBusy
||
Errno
(
rv
)
==
ErrLocked
{
// TODO Trace busy/locked errors
return
nil
...
...
@@ -101,6 +104,9 @@ func (b *Backup) Run(npage int, sleepNs time.Duration, c chan<- BackupStatus) er
// Finish/stop the backup
// (See http://sqlite.org/c3ref/backup_finish.html#sqlite3backupfinish)
func
(
b
*
Backup
)
Close
()
error
{
if
b
==
nil
{
return
ErrMisuse
}
rv
:=
C
.
sqlite3_backup_finish
(
b
.
sb
)
if
rv
!=
C
.
SQLITE_OK
{
return
Errno
(
rv
)
...
...
backup_test.go
View file @
ffc9c2cd
...
...
@@ -24,4 +24,21 @@ func TestBackup(t *testing.T) {
}()
err
=
bck
.
Run
(
10
,
0
,
cbs
)
checkNoError
(
t
,
err
,
"couldn't do backup: %#v"
)
err
=
bck
.
Close
()
checkNoError
(
t
,
err
,
"couldn't close backup twice: %#v"
)
}
func
TestBackupMisuse
(
t
*
testing
.
T
)
{
db
:=
open
(
t
)
defer
db
.
Close
()
bck
,
err
:=
NewBackup
(
db
,
"main"
,
db
,
"main"
)
if
bck
!=
nil
||
err
==
nil
{
t
.
Error
(
"source and destination must be distinct"
)
}
err
=
bck
.
Run
(
10
,
0
,
nil
)
if
err
==
nil
{
t
.
Error
(
"Misuse expected"
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment