Add initial tests for reqlog package

This commit is contained in:
David Stotijn
2022-01-01 16:11:49 +01:00
parent 4e2eaea499
commit b3225bfb99
7 changed files with 959 additions and 26 deletions

View File

@ -59,7 +59,7 @@ type FindRequestsFilter struct {
type Config struct {
Scope *scope.Scope
Repository Repository
ProjectService *proj.Service
ProjectService proj.Service
BypassOutOfScopeRequests bool
}
@ -71,7 +71,7 @@ func NewService(cfg Config) *Service {
}
cfg.ProjectService.OnProjectOpen(func(_ string) error {
err := svc.loadSettings()
err := svc.repo.FindSettingsByModule(context.Background(), moduleName, svc)
if errors.Is(err, proj.ErrNoSettings) {
return nil
}
@ -82,7 +82,8 @@ func NewService(cfg Config) *Service {
return nil
})
cfg.ProjectService.OnProjectClose(func(_ string) error {
svc.unloadSettings()
svc.BypassOutOfScopeRequests = false
svc.FindReqsFilter = FindRequestsFilter{}
return nil
})
@ -252,12 +253,3 @@ func (f *FindRequestsFilter) UnmarshalJSON(b []byte) error {
return nil
}
func (svc *Service) loadSettings() error {
return svc.repo.FindSettingsByModule(context.Background(), moduleName, svc)
}
func (svc *Service) unloadSettings() {
svc.BypassOutOfScopeRequests = false
svc.FindReqsFilter = FindRequestsFilter{}
}