feat: add embedded testing server for postgres (#9955)

# Which Problems Are Solved

1. there was no embedded database to run tests against
2. there were no tests for postgres/migrate
3. there was no test setup for repository which starts a client for the
embedded database

# How the Problems Are Solved

1. postgres/embedded package was added
2. tests were added
3. TestMain was added incl. an example test

# Additional Changes

none

# Additional Context

closes #9934

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Silvan
2025-05-26 09:31:45 +02:00
committed by GitHub
parent 362420f62b
commit 01180d2a63
11 changed files with 274 additions and 19 deletions

View File

@@ -199,6 +199,44 @@ func (c *MockPoolExecCall) DoAndReturn(f func(context.Context, string, ...any) e
return c
}
// Migrate mocks base method.
func (m *MockPool) Migrate(arg0 context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Migrate", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// Migrate indicates an expected call of Migrate.
func (mr *MockPoolMockRecorder) Migrate(arg0 any) *MockPoolMigrateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Migrate", reflect.TypeOf((*MockPool)(nil).Migrate), arg0)
return &MockPoolMigrateCall{Call: call}
}
// MockPoolMigrateCall wrap *gomock.Call
type MockPoolMigrateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockPoolMigrateCall) Return(arg0 error) *MockPoolMigrateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockPoolMigrateCall) Do(f func(context.Context) error) *MockPoolMigrateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockPoolMigrateCall) DoAndReturn(f func(context.Context) error) *MockPoolMigrateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Query mocks base method.
func (m *MockPool) Query(arg0 context.Context, arg1 string, arg2 ...any) (database.Rows, error) {
m.ctrl.T.Helper()
@@ -391,6 +429,44 @@ func (c *MockClientExecCall) DoAndReturn(f func(context.Context, string, ...any)
return c
}
// Migrate mocks base method.
func (m *MockClient) Migrate(arg0 context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Migrate", arg0)
ret0, _ := ret[0].(error)
return ret0
}
// Migrate indicates an expected call of Migrate.
func (mr *MockClientMockRecorder) Migrate(arg0 any) *MockClientMigrateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Migrate", reflect.TypeOf((*MockClient)(nil).Migrate), arg0)
return &MockClientMigrateCall{Call: call}
}
// MockClientMigrateCall wrap *gomock.Call
type MockClientMigrateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockClientMigrateCall) Return(arg0 error) *MockClientMigrateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockClientMigrateCall) Do(f func(context.Context) error) *MockClientMigrateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockClientMigrateCall) DoAndReturn(f func(context.Context) error) *MockClientMigrateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Query mocks base method.
func (m *MockClient) Query(arg0 context.Context, arg1 string, arg2 ...any) (database.Rows, error) {
m.ctrl.T.Helper()