@@ -28,6 +28,7 @@ import (
2828 "github.com/cloudbase/garm/auth"
2929 "github.com/cloudbase/garm/config"
3030 "github.com/cloudbase/garm/database/common"
31+ "github.com/cloudbase/garm/database/watcher"
3132 garmTesting "github.com/cloudbase/garm/internal/testing"
3233 "github.com/cloudbase/garm/params"
3334)
@@ -51,13 +52,19 @@ type GithubTestSuite struct {
5152}
5253
5354func (s * GithubTestSuite ) SetupTest () {
55+ ctx := context .Background ()
56+ watcher .InitWatcher (ctx )
5457 db , err := NewSQLDatabase (context .Background (), garmTesting .GetTestSqliteDBConfig (s .T ()))
5558 if err != nil {
5659 s .FailNow (fmt .Sprintf ("failed to create db connection: %s" , err ))
5760 }
5861 s .db = db
5962}
6063
64+ func (s * GithubTestSuite ) TearDownTest () {
65+ watcher .CloseWatcher ()
66+ }
67+
6168func (s * GithubTestSuite ) TestDefaultEndpointGetsCreatedAutomaticallyIfNoOtherEndpointExists () {
6269 ctx := garmTesting .ImpersonateAdminContext (context .Background (), s .db , s .T ())
6370 endpoint , err := s .db .GetGithubEndpoint (ctx , defaultGithubEndpoint )
@@ -946,14 +953,16 @@ func TestCredentialsAndEndpointMigration(t *testing.T) {
946953 // Set the config credentials in the cfg. This is what happens in the main function.
947954 // of GARM as well.
948955 cfg .MigrateCredentials = credentials
949-
950- db , err := NewSQLDatabase (context .Background (), cfg )
956+ ctx := context .Background ()
957+ watcher .InitWatcher (ctx )
958+ defer watcher .CloseWatcher ()
959+ db , err := NewSQLDatabase (ctx , cfg )
951960 if err != nil {
952961 t .Fatalf ("failed to create db connection: %s" , err )
953962 }
954963
955964 // We expect that 2 endpoints will exist in the migrated DB and 2 credentials.
956- ctx : = garmTesting .ImpersonateAdminContext (context . Background () , db , t )
965+ ctx = garmTesting .ImpersonateAdminContext (ctx , db , t )
957966
958967 endpoints , err := db .ListGithubEndpoints (ctx )
959968 if err != nil {
0 commit comments