github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/storage/temp_engine_test.go (about) 1 // Copyright 2017 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package storage 12 13 import ( 14 "testing" 15 16 "github.com/cockroachdb/cockroach/pkg/base" 17 "github.com/cockroachdb/cockroach/pkg/testutils" 18 "github.com/cockroachdb/cockroach/pkg/util/leaktest" 19 ) 20 21 func TestNewRocksDBTempEngine(t *testing.T) { 22 defer leaktest.AfterTest(t)() 23 24 // Create the temporary directory for the RocksDB engine. 25 tempDir, tempDirCleanup := testutils.TempDir(t) 26 defer tempDirCleanup() 27 28 engine, _, err := NewRocksDBTempEngine(base.TempStorageConfig{Path: tempDir}, base.StoreSpec{Path: tempDir}) 29 if err != nil { 30 t.Fatalf("error encountered when invoking NewRocksDBTempEngine: %+v", err) 31 } 32 defer engine.Close() 33 34 // Temp engine initialized with the temporary directory. 35 if dir := engine.(*rocksDBTempEngine).db.cfg.StorageConfig.Dir; tempDir != dir { 36 t.Fatalf("temp engine initialized with unexpected parent directory.\nexpected %s\nactual %s", 37 tempDir, dir) 38 } 39 }