mock

package
v0.0.0-...-3c0424e Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommerceVendor

type CommerceVendor struct{}

A CommerceVendor mocks a commerce vendor API.

func (*CommerceVendor) GetProductByID

func (c *CommerceVendor) GetProductByID(
	ctx context.Context,
	productID int,
) (app.CommerceProduct, error)

GetProductByID will fetch a product by its ID number from the vendor's catalog.

func (*CommerceVendor) Search

Search will query the vendor's catalog and return matching items.

type DB

type DB struct{}

DB is a mock of interface app.DataStore. It shall implement all of its methods, each of which does nothing.

This can be useful for tests, where this type may be embedded in a more specific mock with overrided methods.

func (*DB) ActivatePerson

func (db *DB) ActivatePerson(
	ctx context.Context,
	personID int,
) error

ActivatePerson mocks activating a person's account.

func (*DB) AddPersonAffiliation

func (db *DB) AddPersonAffiliation(
	ctx context.Context,
	personID, orgID int,
	role app.Role,
) error

AddPersonAffiliation mocks adding an affiliation for a person.

func (*DB) AddProduct

func (db *DB) AddProduct(ctx context.Context, p app.Product) (int, error)

AddProduct mocks adding a product to the catalog.

func (*DB) CreateApplication

func (db *DB) CreateApplication(
	ctx context.Context,
	a app.Application,
) (int, error)

CreateApplication mocks creating an application in the database.

func (*DB) CreateOrganization

func (db *DB) CreateOrganization(
	ctx context.Context,
	org app.Organization,
) (int, error)

CreateOrganization mocks creating a new organization.

func (*DB) CreatePerson

func (db *DB) CreatePerson(ctx context.Context, p app.Person) (int, error)

CreatePerson mocks creating a new person.

func (*DB) CreateSession

func (db *DB) CreateSession(ctx context.Context, s app.Session) (int, error)

CreateSession mocks creating a new session.

func (*DB) DeactivatePerson

func (db *DB) DeactivatePerson(
	ctx context.Context,
	personID int,
) error

DeactivatePerson mocks deactivating a person's account.

func (*DB) DeleteOrganization

func (db *DB) DeleteOrganization(ctx context.Context, orgID int) error

DeleteOrganization mocks deleting an organization.

func (*DB) GetAllOrganizations

func (db *DB) GetAllOrganizations(
	ctx context.Context,
) ([]app.Organization, error)

GetAllOrganizations mocks fetching all organizations.

func (*DB) GetAllPeople

func (db *DB) GetAllPeople(ctx context.Context) ([]app.Person, error)

GetAllPeople mocks retrieving all people from the database.

func (*DB) GetApplicationByID

func (db *DB) GetApplicationByID(
	ctx context.Context,
	appID int,
) (app.Application, error)

GetApplicationByID mocks getting an application by its ID number.

func (*DB) GetApplicationsForOrganization

func (db *DB) GetApplicationsForOrganization(
	ctx context.Context,
	orgID int,
) ([]app.Application, error)

GetApplicationsForOrganization mocks getting all applications submitted for an organization.

func (*DB) GetApplicationsForPerson

func (db *DB) GetApplicationsForPerson(
	ctx context.Context,
	personID int,
) ([]app.Application, error)

GetApplicationsForPerson mocks getting all applications submitted by a person.

func (*DB) GetBalancesForPerson

func (db *DB) GetBalancesForPerson(
	ctx context.Context,
	personID int,
) ([]app.Balance, error)

GetBalancesForPerson mocks fetching a person's balances.

func (*DB) GetOrganizationByID

func (db *DB) GetOrganizationByID(
	ctx context.Context,
	orgID int,
) (app.Organization, error)

GetOrganizationByID mocks fetching an organization by its ID number.

func (*DB) GetPersonByEmail

func (db *DB) GetPersonByEmail(
	ctx context.Context,
	email string,
) (app.Person, error)

GetPersonByEmail mocks fetching a person by their email address.

func (*DB) GetPersonByID

func (db *DB) GetPersonByID(
	ctx context.Context,
	personID int,
) (app.Person, error)

GetPersonByID mocks fetching a person by their ID.

func (*DB) GetProductByID

func (db *DB) GetProductByID(
	ctx context.Context,
	productID, orgID int,
) (app.CatalogProduct, error)

GetProductByID mocks fetching a product by its matching product ID and organization ID numbers.

func (*DB) GetProductsForOrganization

func (db *DB) GetProductsForOrganization(
	ctx context.Context,
	orgID int,
) ([]app.CatalogProduct, error)

GetProductsForOrganization mocks fetching all products for an organization.

func (*DB) GetSessionByToken

func (db *DB) GetSessionByToken(
	ctx context.Context,
	token uuid.UUID,
) (app.Session, error)

GetSessionByToken mocks fetching a session by its token.

func (*DB) GetSessionsForPerson

func (db *DB) GetSessionsForPerson(ctx context.Context,
	personID int,
	includeInvalid bool,
) ([]app.Session, error)

GetSessionsForPerson mocks fetching all sessions for a person.

func (*DB) MakeProductUnavailable

func (db *DB) MakeProductUnavailable(
	ctx context.Context,
	productID, orgID int,
) error

MakeProductUnavailable mocks making a product unavailable in the catalog.

func (*DB) RemovePersonAffiliation

func (db *DB) RemovePersonAffiliation(
	ctx context.Context,
	personID, orgID int,
) error

RemovePersonAffiliation mocks removing a person's affiliation.

func (*DB) RevokeSession

func (db *DB) RevokeSession(ctx context.Context, sessionID int) error

RevokeSession mocks revoking a session.

func (*DB) RevokeSessionsForPersonExcept

func (db *DB) RevokeSessionsForPersonExcept(
	ctx context.Context,
	personID, sessionID int,
) error

RevokeSessionsForPersonExcept mocks revoking all sessions for a person except for the session with matching token.

func (*DB) SearchProductCatalog

func (db *DB) SearchProductCatalog(
	ctx context.Context,
	orgID int,
	keywords string,
) ([]app.CatalogProduct, error)

SearchProductCatalog mocks searching the product catalog.

func (*DB) SetPointsForAffiliation

func (db *DB) SetPointsForAffiliation(
	ctx context.Context,
	personID, orgID int,
	points null.Int,
) error

SetPointsForAffiliation mocks setting points for an affiliation.

func (*DB) UpdateApplicationApproval

func (db *DB) UpdateApplicationApproval(
	ctx context.Context,
	appID int,
	status bool,
	reason string,
) error

UpdateApplicationApproval mocks setting application approval.

func (*DB) UpdateOrganization

func (db *DB) UpdateOrganization(
	ctx context.Context,
	org app.Organization,
) error

UpdateOrganization mocks updating an organization.

func (*DB) UpdatePersonEmail

func (db *DB) UpdatePersonEmail(
	ctx context.Context,
	personID int,
	email string,
) error

UpdatePersonEmail mocks updating a person's email.

func (*DB) UpdatePersonName

func (db *DB) UpdatePersonName(
	ctx context.Context,
	personID int,
	firstName, lastName string,
) error

UpdatePersonName mocks updating a person's name.

func (*DB) UpdatePersonPassword

func (db *DB) UpdatePersonPassword(
	ctx context.Context,
	personID int,
	p app.Password,
) error

UpdatePersonPassword mocks updating a person's password.

func (*DB) UpdatePersonRole

func (db *DB) UpdatePersonRole(
	ctx context.Context,
	personID int,
	roleType app.Role,
) error

UpdatePersonRole mocks updating a person's role.

type HTTPClient

type HTTPClient struct {
	Response string
	Code     int
	Err      error
}

HTTPClient mocks an http.Client by answering any call to the Do method with the given fields.

func (*HTTPClient) Do

func (c *HTTPClient) Do(_ *http.Request) (res *http.Response, err error)

Do accepts an http.Request (ignores its value) and crafts an appropriate response based on the fields set.

If the Err field is not nil, the response will be nil and vice versa.

func (*HTTPClient) Reset

func (c *HTTPClient) Reset()

Reset clears all fields of the mock HTTPClient.

Jump to

Keyboard shortcuts

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