[#668] shard/test: Release shard in t.Cleanup()
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
382eb8a485
commit
429f941cda
6 changed files with 3 additions and 7 deletions
|
@ -28,7 +28,6 @@ func TestShard_Delete(t *testing.T) {
|
|||
|
||||
func testShardDelete(t *testing.T, hasWriteCache bool) {
|
||||
sh := newShard(t, hasWriteCache)
|
||||
defer releaseShard(sh, t)
|
||||
|
||||
cnr := cidtest.ID()
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ func TestShard_Get(t *testing.T) {
|
|||
|
||||
func testShardGet(t *testing.T, hasWriteCache bool) {
|
||||
sh := newShard(t, hasWriteCache)
|
||||
defer releaseShard(sh, t)
|
||||
|
||||
var putPrm PutPrm
|
||||
var getPrm GetPrm
|
||||
|
|
|
@ -30,7 +30,6 @@ func TestShard_Head(t *testing.T) {
|
|||
|
||||
func testShardHead(t *testing.T, hasWriteCache bool) {
|
||||
sh := newShard(t, hasWriteCache)
|
||||
defer releaseShard(sh, t)
|
||||
|
||||
var putPrm PutPrm
|
||||
var headPrm HeadPrm
|
||||
|
|
|
@ -27,7 +27,6 @@ func TestShard_Inhume(t *testing.T) {
|
|||
|
||||
func testShardInhume(t *testing.T, hasWriteCache bool) {
|
||||
sh := newShard(t, hasWriteCache)
|
||||
defer releaseShard(sh, t)
|
||||
|
||||
cnr := cidtest.ID()
|
||||
|
||||
|
|
|
@ -18,14 +18,12 @@ func TestShard_List(t *testing.T) {
|
|||
t.Run("without write cache", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
sh := newShard(t, false)
|
||||
defer releaseShard(sh, t)
|
||||
testShardList(t, sh)
|
||||
})
|
||||
|
||||
t.Run("with write cache", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
shWC := newShard(t, true)
|
||||
defer releaseShard(shWC, t)
|
||||
testShardList(t, shWC)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -31,10 +31,12 @@ func (s epochState) CurrentEpoch() uint64 {
|
|||
}
|
||||
|
||||
func newShard(t testing.TB, enableWriteCache bool) *Shard {
|
||||
return newCustomShard(t, t.TempDir(), enableWriteCache,
|
||||
sh := newCustomShard(t, t.TempDir(), enableWriteCache,
|
||||
writecacheconfig.Options{Type: writecacheconfig.TypeBBolt},
|
||||
nil,
|
||||
nil)
|
||||
t.Cleanup(func() { releaseShard(sh, t) })
|
||||
return sh
|
||||
}
|
||||
|
||||
func newCustomShard(t testing.TB, rootPath string, enableWriteCache bool, wcOpts writecacheconfig.Options, bsOpts []blobstor.Option, metaOptions []meta.Option) *Shard {
|
||||
|
|
Loading…
Reference in a new issue