Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APPS-1268 Validate backup/restore namespace exists #244

Merged
merged 13 commits into from
Nov 4, 2024
Prev Previous commit
Next Next commit
update unit tests
korotkov-aerospike committed Oct 23, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
tvdeyen Thomas von Deyen
commit 252b0b1da5eb3e83b6db9d05a941d501ef55e4b6
35 changes: 23 additions & 12 deletions internal/server/handlers/handlers_test.go
Original file line number Diff line number Diff line change
@@ -183,7 +183,7 @@ func (mock backendsHolderMock) GetAllReaders() map[string]service.BackupListRead
type configurationManagerMock struct{}

func (mock configurationManagerMock) Read(_ context.Context) (*model.Config, error) {
return testConfig().ToModel(nil)
return testConfig().ToModel(&MockNamespaceValidator{})
}

func (mock configurationManagerMock) Update(_ context.Context, _ func(*model.Config) error) error {
@@ -203,16 +203,27 @@ func (a *MockConfigApplier) ApplyNewConfig() error {
return nil
}

type MockNamespaceValidator struct{}

func (m *MockNamespaceValidator) MissingNamespaces(_ *model.AerospikeCluster, _ []string) []string {
return nil
}

func (m *MockNamespaceValidator) ValidateRoutines(_ *model.AerospikeCluster, _ *model.Config) error {
return nil
}

func newServiceMock() *Service {
toModel, _ := testConfig().ToModel(nil)
return &Service{
config: toModel,
configApplier: &MockConfigApplier{},
scheduler: quartz.NewStdScheduler(),
restoreManager: restoreManagerMock{},
backupBackends: backendsHolderMock{},
handlerHolder: nil,
configurationManager: configurationManagerMock{},
logger: slog.New(slog.NewJSONHandler(io.Discard, nil)),
}
toModel, _ := testConfig().ToModel(&MockNamespaceValidator{})
return NewService(
toModel,
&MockConfigApplier{},
quartz.NewStdScheduler(),
restoreManagerMock{},
backendsHolderMock{},
nil,
configurationManagerMock{},
slog.New(slog.NewJSONHandler(io.Discard, nil)),
&MockNamespaceValidator{},
)
}