* ********************************************************* Functions for persisting test data, including db file and operation history ********************************************************* */
(t *testing.T, db *bolt.DB, rs historyRecords, force bool)
| 544 | ********************************************************* |
| 545 | */ |
| 546 | func saveDataIfFailed(t *testing.T, db *bolt.DB, rs historyRecords, force bool) { |
| 547 | if t.Failed() || force { |
| 548 | t.Log("Saving data...") |
| 549 | dbPath := db.Path() |
| 550 | if err := db.Close(); err != nil { |
| 551 | t.Errorf("Failed to close db: %v", err) |
| 552 | } |
| 553 | backupPath := testResultsDirectory(t) |
| 554 | backupDB(t, dbPath, backupPath) |
| 555 | persistHistoryRecords(t, rs, backupPath) |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | func backupDB(t *testing.T, srcPath string, dstPath string) { |
| 560 | targetFile := filepath.Join(dstPath, "db.bak") |
no test coverage detected