Skip to content
Snippets Groups Projects
Commit c3c5b454 authored by thijsheijden's avatar thijsheijden
Browse files

Added mock database request service

parent b03c075b
No related branches found
No related tags found
No related merge requests found
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
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment