Commit 07b37a71 authored by gwenn's avatar gwenn

Test Backup misuse (continued).

parent 019242dd
......@@ -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))}
}
......
......@@ -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()
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment