Documentation
¶
Overview ¶
mockFactory := new(MockFactory) mockItemStore := new(MockItemStore) mockFactory.On("Item").Return(mockItemStore) mockItemStore.On("Create", ctx, item, opts).Return(nil)
err := mockFactory.Item().Create(ctx, item, opts) assert.NoError(t, err)
Index ¶
- func SetClient(factory Factory)
- type Factory
- type ItemAttributesStore
- type ItemImageStore
- type ItemStore
- type MockFactory
- func (m *MockFactory) Close() error
- func (m *MockFactory) ItemAttributes() ItemAttributesStore
- func (m *MockFactory) ItemImage() ItemImageStore
- func (m *MockFactory) Items() ItemStore
- func (m *MockFactory) Policies() PolicyStore
- func (m *MockFactory) PolicyAudits() PolicyAuditStore
- func (m *MockFactory) Secrets() SecretStore
- func (m *MockFactory) Users() UserStore
- type MockItemStore
- func (m *MockItemStore) Create(ctx context.Context, item *model.Item, opts metav1.CreateOptions) error
- func (m *MockItemStore) Delete(ctx context.Context, id int, opts metav1.DeleteOptions) error
- func (m *MockItemStore) Get(ctx context.Context, id int, opts metav1.GetOptions) (*model.Item, error)
- func (m *MockItemStore) List(ctx context.Context, opts metav1.ListOptions) (*model.ItemList, error)
- func (m *MockItemStore) Update(ctx context.Context, item *model.Item, opts metav1.UpdateOptions) error
- type PolicyAuditStore
- type PolicyStore
- type SecretStore
- type UserStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Factory ¶
type Factory interface { Users() UserStore Secrets() SecretStore Policies() PolicyStore PolicyAudits() PolicyAuditStore Items() ItemStore ItemAttributes() ItemAttributesStore ItemImage() ItemImageStore Close() error }
Factory defines the iam platform storage interface.
type ItemAttributesStore ¶
type ItemAttributesStore 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 ItemImageStore ¶
type ItemImageStore interface { Create(ctx context.Context, itemAttribute *v1.ItemImage, opts metav1.CreateOptions) error Update(ctx context.Context, itemAttribute *v1.ItemImage, opts metav1.UpdateOptions) error Delete(ctx context.Context, id uint64, opts metav1.DeleteOptions) error Get(ctx context.Context, id uint64, opts metav1.GetOptions) (*v1.ItemImage, error) List(ctx context.Context, itemID uint64, opts metav1.ListOptions) ([]*v1.ItemImage, error) // 添加这行 }
ItemAttributeSrv defines functions used to handle item attribute requests.
type ItemStore ¶
type ItemStore 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 Get(ctx context.Context, id int, opts metav1.GetOptions) (*v1.Item, error) List(ctx context.Context, opts metav1.ListOptions) (*v1.ItemList, error) }
ItemStore defines the methods for working with items and their related details in the datastore.
type MockFactory ¶
func (*MockFactory) Close ¶
func (m *MockFactory) Close() error
func (*MockFactory) ItemAttributes ¶
func (m *MockFactory) ItemAttributes() ItemAttributesStore
func (*MockFactory) ItemImage ¶
func (m *MockFactory) ItemImage() ItemImageStore
func (*MockFactory) Items ¶
func (m *MockFactory) Items() ItemStore
func (*MockFactory) Policies ¶
func (m *MockFactory) Policies() PolicyStore
func (*MockFactory) PolicyAudits ¶
func (m *MockFactory) PolicyAudits() PolicyAuditStore
func (*MockFactory) Secrets ¶
func (m *MockFactory) Secrets() SecretStore
func (*MockFactory) Users ¶
func (m *MockFactory) Users() UserStore
type MockItemStore ¶
func (*MockItemStore) Create ¶
func (m *MockItemStore) Create(ctx context.Context, item *model.Item, opts metav1.CreateOptions) error
func (*MockItemStore) Delete ¶
func (m *MockItemStore) Delete(ctx context.Context, id int, opts metav1.DeleteOptions) error
func (*MockItemStore) Get ¶
func (m *MockItemStore) Get(ctx context.Context, id int, opts metav1.GetOptions) (*model.Item, error)
func (*MockItemStore) List ¶
func (m *MockItemStore) List(ctx context.Context, opts metav1.ListOptions) (*model.ItemList, error)
func (*MockItemStore) Update ¶
func (m *MockItemStore) Update(ctx context.Context, item *model.Item, opts metav1.UpdateOptions) error
type PolicyAuditStore ¶
type PolicyAuditStore interface {
ClearOutdated(ctx context.Context, maxReserveDays int) (int64, error)
}
PolicyAuditStore defines the policy_audit storage interface.
type PolicyStore ¶
type PolicyStore 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) }
PolicyStore defines the policy storage interface.
type SecretStore ¶
type SecretStore 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) }
SecretStore defines the secret storage interface.
type UserStore ¶
type UserStore 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) }
UserStore defines the user storage interface.