2018-10-02 21:42:23 +00:00
|
|
|
package mock
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/influxdata/platform"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ platform.UserResourceMappingService = &UserResourceMappingService{}
|
|
|
|
|
2018-10-22 20:06:22 +00:00
|
|
|
// UserResourceMappingService is a mock implementation of platform.UserResourceMappingService
|
2018-10-02 21:42:23 +00:00
|
|
|
type UserResourceMappingService struct {
|
2018-10-16 22:14:16 +00:00
|
|
|
FindMappingsFn func(context.Context, platform.UserResourceMappingFilter) ([]*platform.UserResourceMapping, int, error)
|
|
|
|
CreateMappingFn func(context.Context, *platform.UserResourceMapping) error
|
|
|
|
DeleteMappingFn func(context.Context, platform.ID, platform.ID) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewUserResourceMappingService returns a mock of UserResourceMappingService
|
|
|
|
// where its methods will return zero values.
|
|
|
|
func NewUserResourceMappingService() *UserResourceMappingService {
|
|
|
|
return &UserResourceMappingService{
|
|
|
|
FindMappingsFn: func(context.Context, platform.UserResourceMappingFilter) ([]*platform.UserResourceMapping, int, error) {
|
|
|
|
return nil, 0, nil
|
|
|
|
},
|
|
|
|
CreateMappingFn: func(context.Context, *platform.UserResourceMapping) error { return nil },
|
|
|
|
DeleteMappingFn: func(context.Context, platform.ID, platform.ID) error { return nil },
|
|
|
|
}
|
2018-10-02 21:42:23 +00:00
|
|
|
}
|
|
|
|
|
2018-10-22 20:06:22 +00:00
|
|
|
// FindUserResourceMappings finds mappings that match a given filter.
|
2018-10-02 21:42:23 +00:00
|
|
|
func (s *UserResourceMappingService) FindUserResourceMappings(ctx context.Context, filter platform.UserResourceMappingFilter, opt ...platform.FindOptions) ([]*platform.UserResourceMapping, int, error) {
|
2018-10-16 22:14:16 +00:00
|
|
|
return s.FindMappingsFn(ctx, filter)
|
2018-10-02 21:42:23 +00:00
|
|
|
}
|
|
|
|
|
2018-10-22 20:06:22 +00:00
|
|
|
// CreateUserResourceMapping creates a new UserResourceMapping.
|
2018-10-02 21:42:23 +00:00
|
|
|
func (s *UserResourceMappingService) CreateUserResourceMapping(ctx context.Context, m *platform.UserResourceMapping) error {
|
2018-10-16 22:14:16 +00:00
|
|
|
return s.CreateMappingFn(ctx, m)
|
2018-10-02 21:42:23 +00:00
|
|
|
}
|
|
|
|
|
2018-10-22 20:06:22 +00:00
|
|
|
// DeleteUserResourceMapping removes a UserResourceMapping.
|
2018-10-02 21:42:23 +00:00
|
|
|
func (s *UserResourceMappingService) DeleteUserResourceMapping(ctx context.Context, resourceID platform.ID, userID platform.ID) error {
|
2018-10-16 22:14:16 +00:00
|
|
|
return s.DeleteMappingFn(ctx, resourceID, userID)
|
2018-10-02 21:42:23 +00:00
|
|
|
}
|