diff --git a/database/resource.go b/database/resource.go index 1ff9c929c..9f3502162 100644 --- a/database/resource.go +++ b/database/resource.go @@ -6,6 +6,7 @@ package database import ( "github.com/go-vela/server/database/build" + "github.com/go-vela/server/database/executable" "github.com/go-vela/server/database/hook" "github.com/go-vela/server/database/log" "github.com/go-vela/server/database/pipeline" @@ -32,6 +33,17 @@ func (e *engine) NewResources() error { return err } + // create the database agnostic engine for build_executables + e.BuildExecutableInterface, err = executable.New( + executable.WithClient(e.client), + executable.WithLogger(e.logger), + executable.WithSkipCreation(e.config.SkipCreation), + executable.WithDriver(e.config.Driver), + ) + if err != nil { + return err + } + // create the database agnostic engine for hooks e.HookInterface, err = hook.New( hook.WithClient(e.client), diff --git a/database/resource_test.go b/database/resource_test.go index 36a4694e6..800d35ca3 100644 --- a/database/resource_test.go +++ b/database/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/DATA-DOG/go-sqlmock" "github.com/go-vela/server/database/build" + "github.com/go-vela/server/database/executable" "github.com/go-vela/server/database/hook" "github.com/go-vela/server/database/log" "github.com/go-vela/server/database/pipeline" @@ -31,6 +32,8 @@ func TestDatabase_Engine_NewResources(t *testing.T) { _mock.ExpectExec(build.CreateRepoIDIndex).WillReturnResult(sqlmock.NewResult(1, 1)) _mock.ExpectExec(build.CreateSourceIndex).WillReturnResult(sqlmock.NewResult(1, 1)) _mock.ExpectExec(build.CreateStatusIndex).WillReturnResult(sqlmock.NewResult(1, 1)) + // ensure the mock expects the build executable queries + _mock.ExpectExec(executable.CreatePostgresTable).WillReturnResult(sqlmock.NewResult(1, 1)) // ensure the mock expects the hook queries _mock.ExpectExec(hook.CreatePostgresTable).WillReturnResult(sqlmock.NewResult(1, 1)) _mock.ExpectExec(hook.CreateRepoIDIndex).WillReturnResult(sqlmock.NewResult(1, 1))