Documentation ¶
Index ¶
- func EqualStructs(a interface{}, b interface{}) bool
- func ExtractResponse[T any](w *httptest.ResponseRecorder) (*T, int, error)
- func GetDefaultBusiness(user *User) *Business
- func GetDefaultItem(business *Business) *ItemDefinition
- func GetDefaultOwnedItem(itemDefinition *ItemDefinition, card *VirtualCard) *OwnedItem
- func GetDefaultUser() *User
- func GetTestBusiness(db GormDB, user *User) *Business
- func GetTestDatabase() *GormDBImpl
- func GetTestFileMetadata(db GormDB, user *User) *FileMetadata
- func GetTestItemDefinition(db GormDB, business *Business, metadata FileMetadata) *ItemDefinition
- func GetTestItemDefinitionWithPrice(db GormDB, business *Business, metadata FileMetadata, price uint) *ItemDefinition
- func GetTestLocalCard(db GormDB, user *User) *LocalCard
- func GetTestMenuImage(db GormDB, business *Business) *MenuImage
- func GetTestOwnedItem(db GormDB, itemDefinition *ItemDefinition, card *VirtualCard) *OwnedItem
- func GetTestOwnedItemUsed(db GormDB, itemDefinition *ItemDefinition, card *VirtualCard) *OwnedItem
- func GetTestSessionToken(db GormDB, user *User, expires time.Time) (*Token, string)
- func GetTestToken(db GormDB, user *User) (*Token, string)
- func GetTestTransaction(db GormDB, virtualCard *VirtualCard, items []OwnedItem) (*Transaction, []TransactionDetail)
- func GetTestUser(db GormDB) *User
- func GetTestVirtualCard(db GormDB, user *User, business *Business) *VirtualCard
- func GetTestVirtualCardWithPoints(db GormDB, user *User, business *Business, points uint) *VirtualCard
- func MatchEntities(matcher interface{}, Obj interface{}) bool
- func Ptr[T Copyable](s T) *T
- func RecreateDatabase(db GormDB, databaseName string) error
- func ReturnArg(arg interface{}) interface{}
- func Save(db GormDB, item any)
- func TestFileReader(filename string) (io.Reader, string)
- func TestFileReaderWithoutMultipart(filename string) io.Reader
- func TimeJustAroundNow(x time.Time) bool
- type Anything
- type Copyable
- type StructMatcher
- type TestContextBuilder
- func (tc *TestContextBuilder) AddQueryParam(paramName string, paramValue string) *TestContextBuilder
- func (tc *TestContextBuilder) AttachTestJpeg() *TestContextBuilder
- func (tc *TestContextBuilder) AttachTestPng() *TestContextBuilder
- func (tc *TestContextBuilder) SetBody(jsonBytes []byte) *TestContextBuilder
- func (tc *TestContextBuilder) SetDefaultToken() *TestContextBuilder
- func (tc *TestContextBuilder) SetDefaultUrl() *TestContextBuilder
- func (tc *TestContextBuilder) SetDefaultUser() *TestContextBuilder
- func (tc *TestContextBuilder) SetEndpoint(endpointPath string) *TestContextBuilder
- func (tc *TestContextBuilder) SetHeader(headerKey string, headerValue string) *TestContextBuilder
- func (tc *TestContextBuilder) SetMethod(method string) *TestContextBuilder
- func (tc *TestContextBuilder) SetParam(key string, value string) *TestContextBuilder
- func (tc *TestContextBuilder) SetTestFile(filename string) *TestContextBuilder
- func (tc *TestContextBuilder) SetToken(token string) *TestContextBuilder
- func (tc *TestContextBuilder) SetUrl(argUrl *url.URL) *TestContextBuilder
- func (tc *TestContextBuilder) SetUser(u *database.User) *TestContextBuilder
- type TimeGreaterThanNow
- type TimeJustBeforeNow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EqualStructs ¶
func EqualStructs(a interface{}, b interface{}) bool
func ExtractResponse ¶
func ExtractResponse[T any](w *httptest.ResponseRecorder) (*T, int, error)
func GetDefaultBusiness ¶
func GetDefaultBusiness(user *User) *Business
func GetDefaultItem ¶
func GetDefaultItem(business *Business) *ItemDefinition
func GetDefaultOwnedItem ¶
func GetDefaultOwnedItem(itemDefinition *ItemDefinition, card *VirtualCard) *OwnedItem
func GetDefaultUser ¶
func GetDefaultUser() *User
func GetTestBusiness ¶
func GetTestBusiness(db GormDB, user *User) *Business
func GetTestDatabase ¶
func GetTestDatabase() *GormDBImpl
Creates a new database connection from environment variables. Wipes the database. TEST_DATABASE_URL - database URL, ex. 'postgres://postgres@localhost/stampwallet' TEST_DATABASE_NAME - database name, ex. 'stampwallet' NOTE NEVER CALL THIS FROM PARALLEL TESTS. MAKE SURE go test HAD `-p 1` PARAMETER otherwise existing db connections might unexpectedly close. TODO move connection closing to tests
func GetTestFileMetadata ¶
func GetTestFileMetadata(db GormDB, user *User) *FileMetadata
func GetTestItemDefinition ¶
func GetTestItemDefinition(db GormDB, business *Business, metadata FileMetadata) *ItemDefinition
func GetTestItemDefinitionWithPrice ¶
func GetTestItemDefinitionWithPrice(db GormDB, business *Business, metadata FileMetadata, price uint) *ItemDefinition
func GetTestLocalCard ¶
func GetTestLocalCard(db GormDB, user *User) *LocalCard
func GetTestMenuImage ¶
func GetTestMenuImage(db GormDB, business *Business) *MenuImage
func GetTestOwnedItem ¶
func GetTestOwnedItem(db GormDB, itemDefinition *ItemDefinition, card *VirtualCard) *OwnedItem
func GetTestOwnedItemUsed ¶
func GetTestOwnedItemUsed(db GormDB, itemDefinition *ItemDefinition, card *VirtualCard) *OwnedItem
func GetTestSessionToken ¶
func GetTestToken ¶
func GetTestToken(db GormDB, user *User) (*Token, string)
func GetTestTransaction ¶
func GetTestTransaction(db GormDB, virtualCard *VirtualCard, items []OwnedItem) (*Transaction, []TransactionDetail)
func GetTestUser ¶
func GetTestUser(db GormDB) *User
func GetTestVirtualCard ¶
func GetTestVirtualCard(db GormDB, user *User, business *Business) *VirtualCard
func GetTestVirtualCardWithPoints ¶
func GetTestVirtualCardWithPoints(db GormDB, user *User, business *Business, points uint) *VirtualCard
func MatchEntities ¶
func MatchEntities(matcher interface{}, Obj interface{}) bool
Recursively compares matcher with obj. Only keys present in matcher are compared Mostly broken. Should only be used in tests. Note: for exact equality reflect.DeepEqual should be used instead
func RecreateDatabase ¶
Wipes the database
func TimeJustAroundNow ¶
Types ¶
type StructMatcher ¶
type StructMatcher struct {
Obj interface{}
}
func (StructMatcher) Matches ¶
func (matcher StructMatcher) Matches(x interface{}) bool
func (StructMatcher) String ¶
func (StructMatcher) String() string
type TestContextBuilder ¶
func NewTestContextBuilder ¶
func NewTestContextBuilder(w *httptest.ResponseRecorder) *TestContextBuilder
func TestContextCopy ¶
func TestContextCopy(c *gin.Context) *TestContextBuilder
func (*TestContextBuilder) AddQueryParam ¶
func (tc *TestContextBuilder) AddQueryParam(paramName string, paramValue string) *TestContextBuilder
func (*TestContextBuilder) AttachTestJpeg ¶
func (tc *TestContextBuilder) AttachTestJpeg() *TestContextBuilder
func (*TestContextBuilder) AttachTestPng ¶
func (tc *TestContextBuilder) AttachTestPng() *TestContextBuilder
func (*TestContextBuilder) SetBody ¶
func (tc *TestContextBuilder) SetBody(jsonBytes []byte) *TestContextBuilder
func (*TestContextBuilder) SetDefaultToken ¶
func (tc *TestContextBuilder) SetDefaultToken() *TestContextBuilder
func (*TestContextBuilder) SetDefaultUrl ¶
func (tc *TestContextBuilder) SetDefaultUrl() *TestContextBuilder
func (*TestContextBuilder) SetDefaultUser ¶
func (tc *TestContextBuilder) SetDefaultUser() *TestContextBuilder
func (*TestContextBuilder) SetEndpoint ¶
func (tc *TestContextBuilder) SetEndpoint(endpointPath string) *TestContextBuilder
func (*TestContextBuilder) SetHeader ¶
func (tc *TestContextBuilder) SetHeader(headerKey string, headerValue string) *TestContextBuilder
func (*TestContextBuilder) SetMethod ¶
func (tc *TestContextBuilder) SetMethod(method string) *TestContextBuilder
func (*TestContextBuilder) SetParam ¶
func (tc *TestContextBuilder) SetParam(key string, value string) *TestContextBuilder
func (*TestContextBuilder) SetTestFile ¶
func (tc *TestContextBuilder) SetTestFile(filename string) *TestContextBuilder
Overwrites request body Lifted from https://github.com/gin-gonic/gin/blob/master/context_test.go > TestContextFormFile
func (*TestContextBuilder) SetToken ¶
func (tc *TestContextBuilder) SetToken(token string) *TestContextBuilder
func (*TestContextBuilder) SetUrl ¶
func (tc *TestContextBuilder) SetUrl(argUrl *url.URL) *TestContextBuilder
func (*TestContextBuilder) SetUser ¶
func (tc *TestContextBuilder) SetUser(u *database.User) *TestContextBuilder
type TimeGreaterThanNow ¶
func (TimeGreaterThanNow) Matches ¶
func (matcher TimeGreaterThanNow) Matches(x interface{}) bool
func (TimeGreaterThanNow) String ¶
func (TimeGreaterThanNow) String() string
type TimeJustBeforeNow ¶
type TimeJustBeforeNow struct { }
func (TimeJustBeforeNow) Matches ¶
func (matcher TimeJustBeforeNow) Matches(x interface{}) bool
func (TimeJustBeforeNow) String ¶
func (TimeJustBeforeNow) String() string