MCPcopy
hub / github.com/etcd-io/bbolt / saveDataIfFailed

Function saveDataIfFailed

concurrent_test.go:546–557  ·  view source on GitHub ↗

* ********************************************************* Functions for persisting test data, including db file and operation history ********************************************************* */

(t *testing.T, db *bolt.DB, rs historyRecords, force bool)

Source from the content-addressed store, hash-verified

544*********************************************************
545*/
546func 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
559func backupDB(t *testing.T, srcPath string, dstPath string) {
560 targetFile := filepath.Join(dstPath, "db.bak")

Callers 1

concurrentReadAndWriteFunction · 0.85

Calls 6

testResultsDirectoryFunction · 0.85
backupDBFunction · 0.85
persistHistoryRecordsFunction · 0.85
ErrorfMethod · 0.65
PathMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected