add mock implementation of onboarding service

pull/10616/head
zhulongcheng 2019-01-02 11:15:08 +08:00
parent cc1cf89a53
commit 49106f37b4
1 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,41 @@
package mock
import (
"context"
"github.com/influxdata/platform"
)
var _ platform.OnboardingService = (*OnboardingService)(nil)
// OnboardingService is a mock implementation of platform.OnboardingService.
type OnboardingService struct {
BasicAuthService
BucketService
OrganizationService
UserService
AuthorizationService
IsOnboardingFn func(context.Context) (bool, error)
GenerateFn func(context.Context, *platform.OnboardingRequest) (*platform.OnboardingResults, error)
}
// NewOnboardingService returns a mock of OnboardingService where its methods will return zero values.
func NewOnboardingService() *OnboardingService {
return &OnboardingService{
IsOnboardingFn: func(context.Context) (bool, error) { return false, nil },
GenerateFn: func(context.Context, *platform.OnboardingRequest) (*platform.OnboardingResults, error) {
return nil, nil
},
}
}
// IsOnboarding determine if onboarding request is allowed.
func (s *OnboardingService) IsOnboarding(ctx context.Context) (bool, error) {
return s.IsOnboardingFn(ctx)
}
// Generate OnboardingResults.
func (s *OnboardingService) Generate(ctx context.Context, req *platform.OnboardingRequest) (*platform.OnboardingResults, error) {
return s.GenerateFn(ctx, req)
}