fake

package
v0.0.0-...-39f3c58 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MockBool      = mock.AnythingOfType("bool")
	MockBoolPtr   = mock.AnythingOfType("*bool")
	MockInt64     = mock.AnythingOfType("int64")
	MockInt64Ptr  = mock.AnythingOfType("*int64")
	MockString    = mock.AnythingOfType("string")
	MockStringPtr = mock.AnythingOfType("*string")
	MockTime      = mock.AnythingOfType("time.Time")
	MockTimePtr   = mock.AnythingOfType("*time.Time")
	MockContext   = mock.MatchedBy(func(_ context.Context) bool { return true })
)

Functions

This section is empty.

Types

type FakeOrganization

type FakeOrganization struct {
	organization.Organization
}

FakeOrganization is a fake organization for testing. It embeds the organization.Organization struct to inherit its fields. This is useful when you want to add custom fields or methods to the fake organization.

func NewOrganization

func NewOrganization(db database.Database, options ...OrganizationOption) *FakeOrganization

NewOrganization creates a fake organization for testing.

func (*FakeOrganization) AddUser

func (o *FakeOrganization) AddUser(db database.Database, userOptions ...UserOption) *FakeUser

AddUser creates a fake user under the organization.

func (*FakeOrganization) Delete

func (o *FakeOrganization) Delete(db database.Database)

Delete deletes the organization from the database. Use it when you want to delete the organization after it's created. If you want to delete the organization during creation, use OrganizationDeleted option.

func (*FakeOrganization) FetchLatest

func (o *FakeOrganization) FetchLatest(db database.Database) *FakeOrganization

FetchLatest fetches and returns the latest version of organization by querying the database.

func (*FakeOrganization) IsDeleted

func (o *FakeOrganization) IsDeleted(db database.Database) bool

IsDeleted returns deleted status of the organization by querying the database.

func (*FakeOrganization) IsSuspended

func (o *FakeOrganization) IsSuspended(db database.Database) bool

IsSuspended returns suspended status of the organization by querying the database.

type FakeUser

type FakeUser struct {
	user.User
	// contains filtered or unexported fields
}

FakeUser is a fake user for testing. It embeds the user.User struct to inherit its fields. This is useful when you want to add custom fields or methods to the fake user.

func NewUser

func NewUser(db database.Database, orgID int64, options ...UserOption) *FakeUser

NewUser creates a fake user for testing.

func (*FakeUser) FetchLatest

func (u *FakeUser) FetchLatest(db database.Database) *FakeUser

FetchLatest fetches and returns the latest version of user by querying the database.

func (*FakeUser) IsDeleted

func (u *FakeUser) IsDeleted(db database.Database) bool

IsDeleted returns deleted status of the user by querying the database.

func (*FakeUser) IsDisabled

func (u *FakeUser) IsDisabled(db database.Database) bool

IsDisabled returns disabled status of the user by querying the database.

type OrganizationOption

type OrganizationOption func(*FakeOrganization) (*FakeOrganization, error)

OrganizationOption is a function that modifies an organization's default values.

func OrganizationDeleted

func OrganizationDeleted() OrganizationOption

OrganizationDeleted sets deleted_at to current timestamp.

func OrganizationName

func OrganizationName(name string) OrganizationOption

OrganizationName sets/overrides the default name of an organization.

func OrganizationSubdomain

func OrganizationSubdomain(subdomain string) OrganizationOption

OrganizationSubdomain sets/overrides the default subdomain of an organization.

func OrganizationSuspended

func OrganizationSuspended() OrganizationOption

OrganizationSuspended sets suspended_at to current timestamp.

type UserOption

type UserOption func(*FakeUser) (*FakeUser, error)

UserOption is a function that modifies a user's default values.

func UserDeleted

func UserDeleted() UserOption

UserDeleted sets deleted_at to current timestamp.

func UserDisabled

func UserDisabled() UserOption

UserDisabled sets disabled_at to current timestamp.

func UserEmail

func UserEmail(email string) UserOption

UserEmail sets/overrides the default email of a user.

func UserEmailNotVerified

func UserEmailNotVerified() UserOption

UserEmailNotVerified sets is_email_verified to false.

func UserIsOwner

func UserIsOwner() UserOption

UserIsOwner sets the user as the owner of the organization.

func UserPassword

func UserPassword(password string) UserOption

UserPassword sets/overrides the default password of a user.

func UserWithoutToken

func UserWithoutToken() UserOption

UserWithoutToken sets the API token to null.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL