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
07b37a71
Commit
07b37a71
authored
Mar 04, 2012
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test Backup misuse (continued).
parent
019242dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletion
+8
-1
backup.go
backup.go
+6
-0
backup_test.go
backup_test.go
+2
-1
No files found.
backup.go
View file @
07b37a71
...
...
@@ -33,6 +33,9 @@ import (
//
// (See http://sqlite.org/c3ref/backup_finish.html#sqlite3backupinit)
func
NewBackup
(
dst
*
Conn
,
dstDbName
string
,
src
*
Conn
,
srcDbName
string
)
(
*
Backup
,
error
)
{
if
dst
==
nil
||
src
==
nil
{
return
nil
,
errors
.
New
(
"nil sqlite backup source or destination"
)
}
dname
:=
C
.
CString
(
dstDbName
)
sname
:=
C
.
CString
(
srcDbName
)
defer
C
.
free
(
unsafe
.
Pointer
(
dname
))
...
...
@@ -73,6 +76,9 @@ type BackupStatus struct {
// Return the number of pages still to be backed up and the total number of pages in the source database file.
// (See http://sqlite.org/c3ref/backup_finish.html#sqlite3backupremaining)
func
(
b
*
Backup
)
Status
()
BackupStatus
{
if
b
==
nil
{
return
BackupStatus
{}
}
return
BackupStatus
{
int
(
C
.
sqlite3_backup_remaining
(
b
.
sb
)),
int
(
C
.
sqlite3_backup_pagecount
(
b
.
sb
))}
}
...
...
backup_test.go
View file @
07b37a71
...
...
@@ -33,7 +33,7 @@ func TestBackupMisuse(t *testing.T) {
db
:=
open
(
t
)
defer
db
.
Close
()
bck
,
err
:=
NewBackup
(
db
,
"
main"
,
db
,
"main
"
)
bck
,
err
:=
NewBackup
(
db
,
"
"
,
db
,
"
"
)
if
bck
!=
nil
||
err
==
nil
{
t
.
Error
(
"source and destination must be distinct"
)
}
...
...
@@ -41,4 +41,5 @@ func TestBackupMisuse(t *testing.T) {
if
err
==
nil
{
t
.
Error
(
"Misuse expected"
)
}
bck
.
Status
()
}
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