setup

package
v0.0.0-...-9ca37e5 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2018 License: MIT Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config represents the test setup configuration

func NewConfig

func NewConfig(
	statisticsRecorder *StatisticsRecorder,
	defaultMaxCreationTimeDeviation time.Duration,
	serverConfig config.Config,
) *Config

NewConfig creates a new test setup configuration

type Helper

type Helper struct {
	// contains filtered or unexported fields
}

Helper represents a test helper helping perform routine testing tasks

func (*Helper) CreatePost

func (h *Helper) CreatePost(
	author client.ApiClient,
	params api.CreatePostParams,
) *api.Post

CreatePost creates a new post using the given client and parameters and verifies whether the post can be retrieved as well as whether the individual fields are correct

func (*Helper) CreatePostReaction

func (h *Helper) CreatePostReaction(
	postAuthor client.ApiClient,
	reactionAuthor client.ApiClient,
	postIdent api.Identifier,
	reactionType api.PostReactionType,
	description string,
) *api.PostReaction

CreatePostReaction posts a new reaction to any given post using the given client and contents and verifies whether the reaction correctly created

func (*Helper) CreatePosts

func (h *Helper) CreatePosts(
	author client.ApiClient,
	postContents []string,
	readers []client.ApiClient,
) []*api.Post

CreatePosts creates several new posts using the given client and contents and verifies whether the posts are correct and can be read by the given reader clients

func (*Helper) CreateUser

func (h *Helper) CreateUser(
	admin client.ApiClient,
	params api.CreateUserParams,
) (*api.User, client.ApiClient)

CreateUser creates a user profile expecting the operation to be successful, retrieves the profile and verifies whether all fields of the profile are correct

func (*Helper) CreateUserRand

func (h *Helper) CreateUserRand(
	admin client.ApiClient,
	userType api.UserType,
) (*api.User, string, client.ApiClient)

CreateUserRand creates a random user profile with random fields expecting the operation to be successful, retrieves the profile and verifies whether all fields of the profile are correct

func (*Helper) RemovePostReactions

func (h *Helper) RemovePostReactions(
	clt client.ApiClient,
	postReactionsIdents []api.Identifier,
)

RemovePostReactions removes several post reactions using the given client and verifies whether the post reactions can't be retrieved individually

func (*Helper) RemovePosts

func (h *Helper) RemovePosts(
	clt client.ApiClient,
	postsIdents []api.Identifier,
)

RemovePosts removes several posts using the given client and verifies whether the posts can't be retrieved individually

func (*Helper) Time

func (h *Helper) Time(str string) time.Time

Time returns a time.Time object parsed from the given RFC3339 string like: "2014-11-12T11:45:26.371Z"

func (*Helper) VerifyUnauthErr

func (h *Helper) VerifyUnauthErr(err error)

VerifyUnauthErr helps ensuring that the given error is an unauth-error with an error message included

func (*Helper) VerifyWrongCredsErr

func (h *Helper) VerifyWrongCredsErr(err error)

VerifyWrongCredsErr helps ensuring that the given error is a wrong-credentials error with an error message included

type Statistics

type Statistics struct {
	Tests            []*TestStatistics
	MinSetupTime     time.Duration
	MinSetupTimeTest string

	MaxSetupTime     time.Duration
	MaxSetupTimeTest string

	MinTeardownTime     time.Duration
	MinTeardownTimeTest string

	MaxTeardownTime     time.Duration
	MaxTeardownTimeTest string

	AvgSetupTime    time.Duration
	AvgTeardownTime time.Duration
}

Statistics represents the final computed statistics

func (*Statistics) Print

func (st *Statistics) Print()

Print prints the statistics to the standard output

type StatisticsRecorder

type StatisticsRecorder struct {
	// contains filtered or unexported fields
}

StatisticsRecorder represents the statistics recorder and computer

func NewStatisticsRecorder

func NewStatisticsRecorder() *StatisticsRecorder

NewStatisticsRecorder constructs a new statistics recorder instance

func (*StatisticsRecorder) Compute

func (sr *StatisticsRecorder) Compute() *Statistics

Compute will compute and return the final statistics based on the recordings

func (*StatisticsRecorder) Set

func (sr *StatisticsRecorder) Set(
	t *testing.T,
	mutator func(*TestStatistics),
)

Set allows to safely modify a certain tests statistics. It will automatically create a test if it's not yet registered

type TestSetup

type TestSetup struct {
	ApiServer apisrv.ApiServer
	Helper    *Helper
	// contains filtered or unexported fields
}

TestSetup represents the prepared setup of an individual test

func New

func New(t *testing.T, conf *Config) *TestSetup

New creates a new test setup

func (*TestSetup) MaxCreationTimeDeviation

func (ts *TestSetup) MaxCreationTimeDeviation() time.Duration

MaxCreationTimeDeviation returns the configured maximum accepted entity creation time deviation duration

func (*TestSetup) NewAdminClient

func (ts *TestSetup) NewAdminClient(
	username,
	password string,
) client.ApiClient

NewAdminClient creates and connects a new administrator client verifying whether the connection was successfully established and whether the session is correct

func (*TestSetup) NewGuestClient

func (ts *TestSetup) NewGuestClient() client.ApiClient

NewGuestClient creates and connects a new guest client verifying whether the connection was successfully established

func (*TestSetup) NewUserClient

func (ts *TestSetup) NewUserClient(
	username,
	password string,
) client.ApiClient

NewUserClient creates and connects a new regular user client verifying whether the connection was successfully established and whether the session is correct

func (*TestSetup) Teardown

func (ts *TestSetup) Teardown()

Teardown gracefully terminates the test, this method MUST BE DEFERRED until the end of the test!

type TestStatistics

type TestStatistics struct {
	Name         string
	SetupTime    time.Duration
	TeardownTime time.Duration
}

TestStatistics represents the statistics of a specific test

func (*TestStatistics) Clone

func (ts *TestStatistics) Clone() *TestStatistics

Clone returns an exact deep copy of the object

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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