fakeclient.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // Copyright 2020-2021 InfluxData, Inc. All rights reserved.
  2. // Use of this source code is governed by MIT
  3. // license that can be found in the LICENSE file.
  4. // Package examples contains fake client with the same interface as real client to overcome import-cycle problem
  5. // to allow real E2E examples for apis in this package
  6. package examples
  7. import (
  8. "context"
  9. "github.com/influxdata/influxdb-client-go/v2/api"
  10. "github.com/influxdata/influxdb-client-go/v2/domain"
  11. )
  12. // Options is fake options to satisfy Client interface
  13. type Options struct {
  14. }
  15. // SetBatchSize to emulate fake options
  16. func (o *Options) SetBatchSize(_ uint) *Options {
  17. return o
  18. }
  19. // FakeClient emulates Client for allowing using client in api examples
  20. type FakeClient struct {
  21. }
  22. // NewClient returns new FakeClient
  23. func NewClient(_ string, _ string) *FakeClient {
  24. client := &FakeClient{}
  25. return client
  26. }
  27. // Options returns nil
  28. func (c *FakeClient) Options() *Options {
  29. return nil
  30. }
  31. // ServerURL returns empty server URL
  32. func (c *FakeClient) ServerURL() string {
  33. return ""
  34. }
  35. // Ready does nothing
  36. func (c *FakeClient) Ready(_ context.Context) (bool, error) {
  37. return true, nil
  38. }
  39. // Setup does nothing
  40. func (c *FakeClient) Setup(_ context.Context, _, _, _, _ string, _ int) (*domain.OnboardingResponse, error) {
  41. return nil, nil
  42. }
  43. // Health does nothing
  44. func (c *FakeClient) Health(_ context.Context) (*domain.HealthCheck, error) {
  45. return nil, nil
  46. }
  47. // WriteAPI does nothing
  48. func (c *FakeClient) WriteAPI(_, _ string) api.WriteAPI {
  49. return nil
  50. }
  51. // WriteAPIBlocking does nothing
  52. func (c *FakeClient) WriteAPIBlocking(_, _ string) api.WriteAPIBlocking {
  53. return nil
  54. }
  55. // Close does nothing
  56. func (c *FakeClient) Close() {
  57. }
  58. // QueryAPI returns nil
  59. func (c *FakeClient) QueryAPI(_ string) api.QueryAPI {
  60. return nil
  61. }
  62. // AuthorizationsAPI returns nil
  63. func (c *FakeClient) AuthorizationsAPI() api.AuthorizationsAPI {
  64. return nil
  65. }
  66. // OrganizationsAPI returns nil
  67. func (c *FakeClient) OrganizationsAPI() api.OrganizationsAPI {
  68. return nil
  69. }
  70. // UsersAPI returns nil
  71. func (c *FakeClient) UsersAPI() api.UsersAPI {
  72. return nil
  73. }
  74. // DeleteAPI returns nil
  75. func (c *FakeClient) DeleteAPI() api.DeleteAPI {
  76. return nil
  77. }
  78. // BucketsAPI returns nil
  79. func (c *FakeClient) BucketsAPI() api.BucketsAPI {
  80. return nil
  81. }
  82. // LabelsAPI returns nil
  83. func (c *FakeClient) LabelsAPI() api.LabelsAPI {
  84. return nil
  85. }
  86. // TasksAPI returns nil
  87. func (c *FakeClient) TasksAPI() api.TasksAPI {
  88. return nil
  89. }