INNER CODE UNIT · Go

generateRandomTempDBpath

philippgille/gokv · badgerdb/badgerdb_test.go:184

func generateRandomTempDBpath(t *testing.T) string {
	path, err := os.MkdirTemp(os.TempDir(), "BadgerDB")
	if err != nil {
		t.Fatalf("Generating random DB path failed: %v", err)
	}
	return path
}

// cleanUp cleans up (deletes) the database files that have been created during a test.
// If an error occurs the test is NOT marked as failed.
func cleanUp(store gokv.Store, path string) {
	err := store.Close()
	if err != nil {
		log.Printf("Error during cleaning up after a test (during closing the store): %v\n", err)
	}
	err = os.RemoveAll(path)
	if err != nil {
		log.Printf("Error during cleaning up after a test (during removing the data directory): %v\n", err)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…