-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
org_service.go
75 lines (63 loc) · 3.61 KB
/
org_service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package mock
import (
"context"
platform "github.com/influxdata/influxdb/v2"
platform2 "github.com/influxdata/influxdb/v2/kit/platform"
)
var _ platform.OrganizationService = &OrganizationService{}
// OrganizationService is a mock organization server.
type OrganizationService struct {
FindOrganizationByIDF func(ctx context.Context, id platform2.ID) (*platform.Organization, error)
FindOrganizationF func(ctx context.Context, filter platform.OrganizationFilter) (*platform.Organization, error)
FindOrganizationsF func(ctx context.Context, filter platform.OrganizationFilter, opt ...platform.FindOptions) ([]*platform.Organization, int, error)
CreateOrganizationF func(ctx context.Context, b *platform.Organization) error
UpdateOrganizationF func(ctx context.Context, id platform2.ID, upd platform.OrganizationUpdate) (*platform.Organization, error)
DeleteOrganizationF func(ctx context.Context, id platform2.ID) error
FindResourceOrganizationIDF func(ctx context.Context, rt platform.ResourceType, id platform2.ID) (platform2.ID, error)
}
// NewOrganizationService returns a mock OrganizationService where its methods will return
// zero values.
func NewOrganizationService() *OrganizationService {
return &OrganizationService{
FindOrganizationByIDF: func(ctx context.Context, id platform2.ID) (*platform.Organization, error) { return nil, nil },
FindOrganizationF: func(ctx context.Context, filter platform.OrganizationFilter) (*platform.Organization, error) {
return nil, nil
},
FindOrganizationsF: func(ctx context.Context, filter platform.OrganizationFilter, opt ...platform.FindOptions) ([]*platform.Organization, int, error) {
return nil, 0, nil
},
CreateOrganizationF: func(ctx context.Context, b *platform.Organization) error { return nil },
UpdateOrganizationF: func(ctx context.Context, id platform2.ID, upd platform.OrganizationUpdate) (*platform.Organization, error) {
return nil, nil
},
DeleteOrganizationF: func(ctx context.Context, id platform2.ID) error { return nil },
}
}
// FindOrganizationByID calls FindOrganizationByIDF.
func (s *OrganizationService) FindOrganizationByID(ctx context.Context, id platform2.ID) (*platform.Organization, error) {
return s.FindOrganizationByIDF(ctx, id)
}
// FindOrganization calls FindOrganizationF.
func (s *OrganizationService) FindOrganization(ctx context.Context, filter platform.OrganizationFilter) (*platform.Organization, error) {
return s.FindOrganizationF(ctx, filter)
}
// FindOrganizations calls FindOrganizationsF.
func (s *OrganizationService) FindOrganizations(ctx context.Context, filter platform.OrganizationFilter, opt ...platform.FindOptions) ([]*platform.Organization, int, error) {
return s.FindOrganizationsF(ctx, filter, opt...)
}
// CreateOrganization calls CreateOrganizationF.
func (s *OrganizationService) CreateOrganization(ctx context.Context, b *platform.Organization) error {
return s.CreateOrganizationF(ctx, b)
}
// UpdateOrganization calls UpdateOrganizationF.
func (s *OrganizationService) UpdateOrganization(ctx context.Context, id platform2.ID, upd platform.OrganizationUpdate) (*platform.Organization, error) {
return s.UpdateOrganizationF(ctx, id, upd)
}
// DeleteOrganization calls DeleteOrganizationF.
func (s *OrganizationService) DeleteOrganization(ctx context.Context, id platform2.ID) error {
return s.DeleteOrganizationF(ctx, id)
}
// FindResourceOrganizationID calls FindResourceOrganizationIDF.
func (s *OrganizationService) FindResourceOrganizationID(ctx context.Context, rt platform.ResourceType, id platform2.ID) (platform2.ID, error) {
return s.FindResourceOrganizationIDF(ctx, rt, id)
}