dbtest

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2020 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package dbtest allows to temporarily add test data to the database.

Index

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

func (self *Env) CreatePoll(title string, admin uint32, publicity uint8) (pollId uint32)

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) CreateUser

func (self *Env) CreateUser() (userId uint32)

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) 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.

Jump to

Keyboard shortcuts

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