influxdb/mocks/users.go

50 lines
1.4 KiB
Go
Raw Normal View History

2017-02-22 03:36:04 +00:00
package mocks
import (
"context"
"github.com/influxdata/chronograf"
)
2017-02-22 05:54:24 +00:00
var _ chronograf.UsersStore = &UsersStore{}
2017-02-22 03:36:04 +00:00
// UsersStore mock allows all functions to be set for testing
type UsersStore struct {
AllF func(context.Context) ([]chronograf.User, error)
AddF func(context.Context, *chronograf.User) (*chronograf.User, error)
DeleteF func(context.Context, *chronograf.User) error
GetF func(ctx context.Context, q chronograf.UserQuery) (*chronograf.User, error)
2017-02-22 03:36:04 +00:00
UpdateF func(context.Context, *chronograf.User) error
2017-11-30 17:55:59 +00:00
NumF func(context.Context) (int, error)
2017-02-22 03:36:04 +00:00
}
// All lists all users from the UsersStore
func (s *UsersStore) All(ctx context.Context) ([]chronograf.User, error) {
return s.AllF(ctx)
}
2017-11-30 17:55:59 +00:00
// Num returns the number of users in the UsersStore
func (s *UsersStore) Num(ctx context.Context) (int, error) {
return s.NumF(ctx)
}
2017-02-22 03:36:04 +00:00
// Add a new User in the UsersStore
func (s *UsersStore) Add(ctx context.Context, u *chronograf.User) (*chronograf.User, error) {
return s.AddF(ctx, u)
}
// Delete the User from the UsersStore
func (s *UsersStore) Delete(ctx context.Context, u *chronograf.User) error {
return s.DeleteF(ctx, u)
}
// Get retrieves a user if name exists.
func (s *UsersStore) Get(ctx context.Context, q chronograf.UserQuery) (*chronograf.User, error) {
return s.GetF(ctx, q)
2017-02-22 03:36:04 +00:00
}
// Update the user's permissions or roles
func (s *UsersStore) Update(ctx context.Context, u *chronograf.User) error {
return s.UpdateF(ctx, u)
}