Skip to content

Commit

Permalink
storagebuilder function more clean
Browse files Browse the repository at this point in the history
  • Loading branch information
norbertklawikowski committed Jul 3, 2024
1 parent 6da9de6 commit 719be58
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions storagetest/storagetest.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,28 @@ import (
"github.com/lovoo/goka/storage"
)

// TeardownFunc cleans up state after tests.
type TeardownFunc func() error
// TeardownFn cleans up state after tests.
type TeardownFn func() error

// StorageBuilderFn creates a storage and the teardown function.
type StorageBuilderFn func(t *testing.T) (storage.Storage, TeardownFn)

type StorageTestSuite struct {
suite.Suite

storageBuilder func(t *testing.T) (storage.Storage, TeardownFunc)
storage storage.Storage
teardownFn TeardownFunc
storageBuilderFn StorageBuilderFn
teardownFn TeardownFn
storage storage.Storage
}

func NewStorageTestSuite(storageBuilder func(t *testing.T) (storage.Storage, TeardownFunc)) *StorageTestSuite {
func NewStorageTestSuite(storageBuilderFn StorageBuilderFn) *StorageTestSuite {
return &StorageTestSuite{
storageBuilder: storageBuilder,
storageBuilderFn: storageBuilderFn,
}
}

func (s *StorageTestSuite) SetupTest() {
storage, teardownFn := s.storageBuilder(s.T())
storage, teardownFn := s.storageBuilderFn(s.T())
s.storage = storage
s.teardownFn = teardownFn
}
Expand Down

0 comments on commit 719be58

Please sign in to comment.