diff --git a/internal/usecases/request/mock/mockrequest.go b/internal/usecases/request/mock/mockrequest.go new file mode 100644 index 0000000000000000000000000000000000000000..758a0eaa4b83ba433efc97c472b64b911feda519 --- /dev/null +++ b/internal/usecases/request/mock/mockrequest.go @@ -0,0 +1,33 @@ +package mockrequest + +import ( + "errors" + "query-service/internal/entity" +) + +// A Service implements the request usecases (mock) +type Service struct { + throwError bool +} + +// NewService creates a new service (mock) +func NewService() *Service { + return &Service{ + throwError: false, + } +} + +// SendAQLQuery sends the query to arangoDB and parses the result (mock) +func (s *Service) SendAQLQuery(query string) (*map[string][]entity.Document, error) { + mockResult := make(map[string][]entity.Document) + + if !s.throwError { + return &mockResult, nil + } + return nil, errors.New("Database error") +} + +// ToggleError decides whether the convert function throws an error +func (s *Service) ToggleError() { + s.throwError = !s.throwError +}