Documentation ¶
Index ¶
- Constants
- func RandDataString(name string) string
- func RandEmail(username string, domainLength int) string
- func RandInt(max int) int64
- func RandLCLetters(length int) string
- func RandString(length int) string
- type APITest
- func (a *APITest) CheckProfile(profileName string)
- func (a *APITest) Decrement(key string) int64
- func (a *APITest) DestroyProfile(profileName string) (e error)
- func (a *APITest) Finish()
- func (a *APITest) GetInt(name string) int64
- func (a *APITest) GetObject(name string) interface{}
- func (a *APITest) GetProfile(profileName string) (profile *UserProfile, e error)
- func (a *APITest) GetProfileNames() []string
- func (a *APITest) GetString(key string) string
- func (a *APITest) Increment(key string) int64
- func (a *APITest) NewProfile(name string) (userProfile *UserProfile, e error)
- func (a *APITest) Note(note string)
- func (a *APITest) Notef(note string, args ...interface{})
- func (a *APITest) Parallel(description string, doAsFns ...func())
- func (a *APITest) ResetProfileToDefault()
- func (a *APITest) SetActiveProfile(profileName string)
- func (a *APITest) SetInt(name string, v int64) int64
- func (a *APITest) SetObject(key string, obj interface{})
- func (a *APITest) SetString(key, value string) string
- func (a *APITest) Start(title string)
- type LogLevel
- type Logger
- type Requests
- func (r *Requests) Delete(path string, withAuth bool) (responseBody []byte, statusCode int)
- func (r *Requests) DeleteDebug(path string, withAuth bool) (responseBody []byte, statusCode int)
- func (r *Requests) Get(path string, withAuth bool) (responseBody []byte, statusCode int)
- func (r *Requests) GetDebug(path string, withAuth bool) (responseBody []byte, statusCode int)
- func (r *Requests) Post(path string, body interface{}, authenticated bool) (responseBody []byte, statusCode int)
- func (r *Requests) PostDebug(path string, body interface{}, authenticated bool) (responseBody []byte, statusCode int)
- func (r *Requests) Put(path string, body interface{}, authenticated bool) (responseBody []byte, statusCode int)
- func (r *Requests) PutDebug(path string, body interface{}, authenticated bool) (responseBody []byte, statusCode int)
- type UserProfile
- func (u *UserProfile) Decrement(key string) int64
- func (u *UserProfile) GetInt(key string) (val int64)
- func (u *UserProfile) GetObject(key string) (val interface{})
- func (u *UserProfile) GetString(key string) string
- func (u *UserProfile) Increment(key string) int64
- func (u *UserProfile) SetAuthKey(value string) string
- func (u *UserProfile) SetInt(name string, val int64) int64
- func (u *UserProfile) SetObject(key string, obj interface{})
- func (u *UserProfile) SetString(key, value string) string
Constants ¶
const ( DefaultProfileName = "profile0" AuthKey = "authKey" RefreshTokenKey = "refreshToken" )
Variables ¶
This section is empty.
Functions ¶
func RandDataString ¶
RandDataString returns a random data string from `name` set in dataStrings
func RandEmail ¶
RandEmail returns a random email with the username and the length of the domain name provided Domain names and tlds are randomized
func RandLCLetters ¶
RandLCLetters returns a random string of lower case letters from the English alphabet
func RandString ¶
RandString returns a random string based on a set of runes
Types ¶
type APITest ¶
type APITest struct {
// contains filtered or unexported fields
}
APITest tests your API
func NewAPITest ¶
NewAPITest returns a new APITest instance
func (*APITest) CheckProfile ¶
CheckProfile checks a profile
func (*APITest) Decrement ¶
Decrement sets an integer in the number cache if it doesn't exist And then decrements it by 1 The resulting value is returned
func (*APITest) DestroyProfile ¶
DestroyProfile destroys a profile - Cannot destroy the default profile - Cannot destroy the profile if it is the currently active profile
func (*APITest) GetProfile ¶
func (a *APITest) GetProfile(profileName string) (profile *UserProfile, e error)
GetProfile gets a profile by its name
func (*APITest) GetProfileNames ¶
GetProfileNames returns a list of profile names
func (*APITest) GetString ¶
GetString gets the string value identified by `name` from the global cache
func (*APITest) Increment ¶
Increment sets an integer in the number cache if it doesn't exist And then decrements it by 1 The resulting value is returned
func (*APITest) NewProfile ¶
func (a *APITest) NewProfile(name string) (userProfile *UserProfile, e error)
NewProfile creates a user profile indexed by `name`
func (*APITest) Parallel ¶
Parallel runs parallel tests https://gist.github.com/thatisuday/6612075cf0b7e04ef232717f4e8815a3 https://medium.com/statuscode/pipeline-patterns-in-go-a37bb3a7e61d
func (*APITest) ResetProfileToDefault ¶
func (a *APITest) ResetProfileToDefault()
ResetProfileToDefault sets the activeProfile to the default profile
func (*APITest) SetActiveProfile ¶
SetActiveProfile sets the active profile
type Requests ¶
type Requests struct {
// contains filtered or unexported fields
}
Requests sends network requests using `profile` as context
func NewRequests ¶
func NewRequests(profile *UserProfile, logger *Logger, t *testing.T) *Requests
NewRequests returns a new Requests instance
func (*Requests) DeleteDebug ¶
DeleteDebug does a DELETE request while temporarily setting the log level to debug
func (*Requests) GetDebug ¶
GetDebug does a get request while temporarily setting the log level to debug
func (*Requests) Post ¶
func (r *Requests) Post(path string, body interface{}, authenticated bool) (responseBody []byte, statusCode int)
Post does a post request
func (*Requests) PostDebug ¶
func (r *Requests) PostDebug(path string, body interface{}, authenticated bool) (responseBody []byte, statusCode int)
PostDebug does a post request while temporarily setting the log level to debug
type UserProfile ¶
type UserProfile struct { sync.Mutex Name string ID int Requests *Requests Logger *Logger // contains filtered or unexported fields }
UserProfile contains a user-contextual data structure for use within the testing process
func NewUserProfile ¶
NewUserProfile returns a new UserProfile
func (*UserProfile) Decrement ¶
func (u *UserProfile) Decrement(key string) int64
Decrement sets an integer in the number cache if it doesn't exist And then decrements it by 1 The resulting value is returned
func (*UserProfile) GetInt ¶
func (u *UserProfile) GetInt(key string) (val int64)
GetInt gets the int value at profile `profileName` and `key` without changing the current profile
func (*UserProfile) GetObject ¶
func (u *UserProfile) GetObject(key string) (val interface{})
GetObject gets an object at `key` for profile `profileName`
func (*UserProfile) GetString ¶
func (u *UserProfile) GetString(key string) string
GetString returns a string value in profile `profileName` at `key` without changing the active profile
func (*UserProfile) Increment ¶
func (u *UserProfile) Increment(key string) int64
Increment sets an integer in the number cache for profile `profileName` if it doesn't exist And then increments it by 1 The resulting value is returned
func (*UserProfile) SetAuthKey ¶
func (u *UserProfile) SetAuthKey(value string) string
SetAuthKey sets the authentication key for network requests
func (*UserProfile) SetInt ¶
func (u *UserProfile) SetInt(name string, val int64) int64
SetInt sets an int value at `name` for profile `profileName`
func (*UserProfile) SetObject ¶
func (u *UserProfile) SetObject(key string, obj interface{})
SetObject sets an object at `name` for the active user profile
func (*UserProfile) SetString ¶
func (u *UserProfile) SetString(key, value string) string
SetString sets a string value at `key` within the active profile