Documentation
¶
Overview ¶
Package dbtest allows to temporarily add test data to the database.
Index ¶
- type Env
- func (self *Env) Close()
- func (self *Env) CreatePoll(title string, admin uint32, publicity uint8) uint32
- func (self *Env) CreatePollWith(title string, admin uint32, publicity uint8, alternatives []string) (pollId uint32)
- func (self *Env) CreateUser() uint32
- func (self *Env) CreateUserWith(salt string) (userId uint32)
- func (self *Env) Defer(fct func())
- func (self *Env) Must(t *testing.T)
- func (self *Env) NextRound(pollId uint32)
- func (self *Env) QuietExec(query string, args ...interface{})
- func (self *Env) Vote(pollId uint32, round uint8, userId uint32, alternative uint8)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Env ¶
type Env struct {
Error error
// contains filtered or unexported fields
}
Env provides methods to add temporary test data. It collects functions to remove these data. These functions are called by Close, hence a call to Close must be defered for each Env object.
Env's methods never return errors. Instead, the Error field is updated and checked by all methods (except Close).
func (*Env) Close ¶
func (self *Env) Close()
Close calls all collected functions, in reverse order, even if Error is not nil.
func (*Env) CreatePoll ¶
CreatePoll adds a poll to the database. The poll has Salt 42, MaxNbRounds 3, and 2 alternatives 'No' and 'Yes' (in that order). The poll is deleted by Close.
func (*Env) CreatePollWith ¶ added in v0.0.4
func (self *Env) CreatePollWith(title string, admin uint32, publicity uint8, alternatives []string) (pollId uint32)
CreatePoll adds a poll to the database. The poll has Salt 42, MaxNbRounds 3, and the alternatives given as arguments. All alternatives have Cost 1. The poll is deleted by Close.
func (*Env) CreateUser ¶
CreateUser adds a user to the database. The user has name ' Test ' (mind the spaces), email address 'test@example.test', and password 'XYZ'. It is deleted by Close.
func (*Env) CreateUserWith ¶ added in v0.0.4
CreateUser adds a user to the database. The user has name ' Test<salt> ' (mind the spaces), email address 'test<salt>@example.test', and password 'XYZ'. It is deleted by Close.
func (*Env) Defer ¶
func (self *Env) Defer(fct func())
Defer adds a function to be called by Close. As other Env's method, nothing is done if Error is not nil.