Chore: Add initial support for deployment modes (#63992)

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
This commit is contained in:
Todd Treece
2023-03-06 14:06:52 -05:00
committed by GitHub
co-authored by Will Browne
parent 3ebc604bb7
commit e217854c24
9 changed files with 285 additions and 3 deletions
+28 -1
View File
@@ -48,7 +48,7 @@ func (s *testService) IsDisabled() bool {
func testServer(t *testing.T, services ...registry.BackgroundService) *Server {
t.Helper()
s, err := newServer(Options{}, setting.NewCfg(), nil, &acimpl.Service{}, nil, backgroundsvcs.NewBackgroundServiceRegistry(services...))
s, err := newServer(Options{}, setting.NewCfg(), nil, &acimpl.Service{}, nil, backgroundsvcs.NewBackgroundServiceRegistry(services...), &MockModuleService{})
require.NoError(t, err)
// Required to skip configuration initialization that causes
// DI errors in this test.
@@ -90,3 +90,30 @@ func TestServer_Shutdown(t *testing.T) {
err = <-ch
require.NoError(t, err)
}
type MockModuleService struct {
initFunc func(context.Context) error
runFunc func(context.Context) error
shutdownFunc func(context.Context) error
}
func (m *MockModuleService) Init(ctx context.Context) error {
if m.initFunc != nil {
return m.initFunc(ctx)
}
return nil
}
func (m *MockModuleService) Run(ctx context.Context) error {
if m.runFunc != nil {
return m.runFunc(ctx)
}
return nil
}
func (m *MockModuleService) Shutdown(ctx context.Context) error {
if m.shutdownFunc != nil {
return m.shutdownFunc(ctx)
}
return nil
}