Documentation
¶
Overview ¶
mockService := new(MockService) mockItemService := new(MockItemService) mockService.On("Item").Return(mockItemService) mockItemService.On("Create", ctx, item, opts).Return(nil)
err := mockService.Item().Create(ctx, item, opts) assert.NoError(t, err)
Index ¶
- type ItemAttributesSrv
- type ItemImageSrv
- type ItemSrv
- type MockItemService
- func (m *MockItemService) Create(ctx context.Context, item *model.Item, opts metav1.CreateOptions) error
- func (m *MockItemService) Delete(ctx context.Context, id int, opts metav1.DeleteOptions) error
- func (m *MockItemService) Get(ctx context.Context, id int, opts metav1.GetOptions) (*model.Item, error)
- func (m *MockItemService) List(ctx context.Context, opts metav1.ListOptions) (*model.ItemList, error)
- func (m *MockItemService) Update(ctx context.Context, item *model.Item, opts metav1.UpdateOptions) error
- type MockService
- type PolicySrv
- type SecretSrv
- type Service
- type UserSrv
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ItemAttributesSrv ¶
type ItemAttributesSrv interface { Create(ctx context.Context, itemAttribute *v1.ItemAttributes, opts metav1.CreateOptions) error Update(ctx context.Context, itemAttribute *v1.ItemAttributes, opts metav1.UpdateOptions) error Delete(ctx context.Context, id int, opts metav1.DeleteOptions) error Get(ctx context.Context, id int, opts metav1.GetOptions) (*v1.ItemAttributes, error) FindByAttributes(ctx context.Context, attributes *v1.ItemAttributes, opts metav1.ListOptions) (*v1.ItemList, error) }
ItemAttributeSrv defines functions used to handle item attribute requests.
type ItemImageSrv ¶
type ItemImageSrv interface { Create(ctx context.Context, itemImage *model.ItemImage, opts metav1.CreateOptions) error Update(ctx context.Context, itemImage *model.ItemImage, opts metav1.UpdateOptions) error Delete(ctx context.Context, id uint64, opts metav1.DeleteOptions) error Get(ctx context.Context, id uint64, opts metav1.GetOptions) (*model.ItemImage, error) List(ctx context.Context, itemID uint64, opts metav1.ListOptions) ([]*model.ItemImage, error) // 添加这行 }
type ItemSrv ¶
type ItemSrv interface { Create(ctx context.Context, item *v1.Item, opts metav1.CreateOptions) error Update(ctx context.Context, item *v1.Item, opts metav1.UpdateOptions) error Delete(ctx context.Context, id int, opts metav1.DeleteOptions) error // DeleteCollection(ctx context.Context, ids []int, opts metav1.DeleteOptions) error Get(ctx context.Context, id int, opts metav1.GetOptions) (*v1.Item, error) List(ctx context.Context, opts metav1.ListOptions) (*v1.ItemList, error) }
ItemSrv defines functions used to handle item requests.
type MockItemService ¶
func (*MockItemService) Create ¶
func (m *MockItemService) Create(ctx context.Context, item *model.Item, opts metav1.CreateOptions) error
func (*MockItemService) Delete ¶
func (m *MockItemService) Delete(ctx context.Context, id int, opts metav1.DeleteOptions) error
func (*MockItemService) Get ¶
func (m *MockItemService) Get(ctx context.Context, id int, opts metav1.GetOptions) (*model.Item, error)
func (*MockItemService) List ¶
func (m *MockItemService) List(ctx context.Context, opts metav1.ListOptions) (*model.ItemList, error)
func (*MockItemService) Update ¶
func (m *MockItemService) Update(ctx context.Context, item *model.Item, opts metav1.UpdateOptions) error
type MockService ¶
func (*MockService) Item ¶
func (m *MockService) Item() itemService
type PolicySrv ¶
type PolicySrv interface { Create(ctx context.Context, policy *v1.Policy, opts metav1.CreateOptions) error Update(ctx context.Context, policy *v1.Policy, opts metav1.UpdateOptions) error Delete(ctx context.Context, username string, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, username string, names []string, opts metav1.DeleteOptions) error Get(ctx context.Context, username string, name string, opts metav1.GetOptions) (*v1.Policy, error) List(ctx context.Context, username string, opts metav1.ListOptions) (*v1.PolicyList, error) }
PolicySrv defines functions used to handle policy request.
type SecretSrv ¶
type SecretSrv interface { Create(ctx context.Context, secret *v1.Secret, opts metav1.CreateOptions) error Update(ctx context.Context, secret *v1.Secret, opts metav1.UpdateOptions) error Delete(ctx context.Context, username, secretID string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, username string, secretIDs []string, opts metav1.DeleteOptions) error Get(ctx context.Context, username, secretID string, opts metav1.GetOptions) (*v1.Secret, error) List(ctx context.Context, username string, opts metav1.ListOptions) (*v1.SecretList, error) }
SecretSrv defines functions used to handle secret request.
type Service ¶
type Service interface { Users() UserSrv Secrets() SecretSrv Policies() PolicySrv Items() ItemSrv ItemAttributes() ItemAttributesSrv ItemImage() ItemImageSrv }
Service defines functions used to return resource interface.
func NewService ¶
NewService returns Service interface.
type UserSrv ¶
type UserSrv interface { Create(ctx context.Context, user *v1.User, opts metav1.CreateOptions) error Update(ctx context.Context, user *v1.User, opts metav1.UpdateOptions) error Delete(ctx context.Context, username string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, usernames []string, opts metav1.DeleteOptions) error Get(ctx context.Context, username string, opts metav1.GetOptions) (*v1.User, error) List(ctx context.Context, opts metav1.ListOptions) (*v1.UserList, error) ListWithBadPerformance(ctx context.Context, opts metav1.ListOptions) (*v1.UserList, error) ChangePassword(ctx context.Context, user *v1.User) error }
UserSrv defines functions used to handle user request.