Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

test(backup): add view in backup test case (#1523)

Yilong Libcd7dbe50673
diff --git a/tests/backup_restore_test.go b/tests/backup_restore_test.go
index e5acfaa956..994c1d8cf9 100644
--- a/tests/backup_restore_test.go
+++ b/tests/backup_restore_test.go
@@ -58,7 +58,8 @@ func TestBackupRestoreBasic(t *testing.T) {
PRIMARY KEY (id),
CHECK (id >= 0)
);
- `, database, database, table))
+ CREATE VIEW v_%s AS SELECT * FROM %s;
+ `, database, database, table, table, table))
a.NoError(err)
const numRecords = 10
@@ -80,8 +81,8 @@ func TestBackupRestoreBasic(t *testing.T) {
a.NoError(err)
t.Logf("backup content:\n%s", buf.String())
- // drop all tables
- _, err = db.Exec(fmt.Sprintf("DROP TABLE %s", table))
+ // drop all tables and views
+ _, err = db.Exec(fmt.Sprintf("DROP TABLE %s; DROP VIEW v_%s;", table, table))
a.NoError(err)
// restore
@@ -417,10 +418,13 @@ func doBackup(ctx context.Context, driver dbplugin.Driver, database string) (*by
var buf bytes.Buffer
var backupPayload api.BackupPayload
backupPayloadString, err := driver.Dump(ctx, database, &buf, false)
+ if err != nil {
+ return nil, nil, err
+ }
if err := json.Unmarshal([]byte(backupPayloadString), &backupPayload); err != nil {
return nil, nil, err
}
- return &buf, &backupPayload, err
+ return &buf, &backupPayload, nil
}
// Concurrently update a single row to mimic the ongoing business workload.