Skip to content

Commit

Permalink
Add sqlite cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bcmmbaga committed Jun 12, 2024
1 parent 14639af commit 64909be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 7 additions & 3 deletions client/internal/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ func TestEngine_MultiplePeers(t *testing.T) {
return
}
defer sigServer.Stop()
mgmtServer, mgmtAddr, err := startManagement(dir)
mgmtServer, mgmtAddr, err := startManagement(t, dir)
if err != nil {
t.Fatal(err)
return
Expand Down Expand Up @@ -1032,7 +1032,9 @@ func startSignal() (*grpc.Server, string, error) {
return s, lis.Addr().String(), nil
}

func startManagement(dataDir string) (*grpc.Server, string, error) {
func startManagement(t *testing.T, dataDir string) (*grpc.Server, string, error) {
t.Helper()

config := &server.Config{
Stuns: []*server.Host{},
TURNConfig: &server.TURNConfig{},
Expand All @@ -1049,10 +1051,12 @@ func startManagement(dataDir string) (*grpc.Server, string, error) {
return nil, "", err
}
s := grpc.NewServer(grpc.KeepaliveEnforcementPolicy(kaep), grpc.KeepaliveParams(kasp))
store, _, err := server.NewTestStoreFromJson(config.Datadir)

store, cleanUp, err := server.NewTestStoreFromJson(config.Datadir)
if err != nil {
return nil, "", err
}
t.Cleanup(cleanUp)

peersUpdateManager := server.NewPeersUpdateManager(nil)
eventStore := &activity.InMemoryEventStore{}
Expand Down
5 changes: 2 additions & 3 deletions management/server/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,7 @@ func NewTestStoreFromJson(dataDir string) (Store, func(), error) {

var (
store Store
cleanUp = func() {
// empty store cleanUp
}
cleanUp func()
)

if kind == PostgresStoreEngine {
Expand All @@ -221,6 +219,7 @@ func NewTestStoreFromJson(dataDir string) (Store, func(), error) {
if err != nil {
return nil, nil, err
}
cleanUp = func() { store.Close() }
}

return store, cleanUp, nil
Expand Down

0 comments on commit 64909be

Please sign in to comment.