client_fake_api.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package v1
  2. import (
  3. "context"
  4. "net/http"
  5. )
  6. type ClientFakeAPI struct {
  7. MockMe func() (int64, []byte, error)
  8. MockDonates func(page, size int64) (int64, []byte, error)
  9. MockClients func() (int64, []byte, error)
  10. }
  11. func NewClientFakeAPI() *ClientFakeAPI {
  12. return &ClientFakeAPI{
  13. MockMe: func() (int64, []byte, error) {
  14. return http.StatusUnauthorized, []byte(`{"success":false,"message":"Помилка авторизації"}`), nil
  15. },
  16. MockDonates: func(page, size int64) (int64, []byte, error) {
  17. return http.StatusUnauthorized, []byte(`{"success":false,"message":"Помилка авторизації"}`), nil
  18. },
  19. MockClients: func() (int64, []byte, error) {
  20. return http.StatusUnauthorized, []byte(`{"success":false,"message":"Помилка авторизації"}`), nil
  21. },
  22. }
  23. }
  24. func (c *ClientFakeAPI) Me(ctx context.Context) (int64, []byte, error) {
  25. return c.MockMe()
  26. }
  27. func (c *ClientFakeAPI) Donates(ctx context.Context, page, size int64) (int64, []byte, error) {
  28. return c.MockDonates(page, size)
  29. }
  30. func (c *ClientFakeAPI) Clients(ctx context.Context) (int64, []byte, error) {
  31. return c.MockClients()
  32. }