setup

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssumeFailure

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

AssumeFailure wraps failable helper functions

func (AssumeFailure) Authenticate

func (notOk AssumeFailure) Authenticate(
	expectedErrorCode errors.Code,
	sessionKey string,
)

Authenticate helps closing a session

func (AssumeFailure) CloseAllSessions

func (notOk AssumeFailure) CloseAllSessions(
	expectedErrorCode errors.Code,
	user store.ID,
)

CloseAllSessions helps closing all sessions of a user

func (AssumeFailure) CloseSession

func (notOk AssumeFailure) CloseSession(
	expectedErrorCode errors.Code,
	key string,
)

CloseSession helps closing a session

func (AssumeFailure) CreatePost

func (notOk AssumeFailure) CreatePost(
	expectedErrorCode errors.Code,
	authorID store.ID,
	title string,
	contents string,
)

CreatePost helps creating a user

func (AssumeFailure) CreateReaction

func (notOk AssumeFailure) CreateReaction(
	expectedErrorCode errors.Code,
	author store.ID,
	subject store.ID,
	emotion emotion.Emotion,
	message string,
)

CreateReaction helps creating a reaction

func (AssumeFailure) CreateSession

func (notOkay AssumeFailure) CreateSession(
	expectedErrorCode errors.Code,
	email string,
	password string,
)

CreateSession helps creating a new session

func (AssumeFailure) CreateUser

func (notOkay AssumeFailure) CreateUser(
	expectedErrorCode errors.Code,
	displayName,
	email,
	password string,
)

CreateUser helps creating a user

func (AssumeFailure) EditPost

func (notOk AssumeFailure) EditPost(
	expectedErrorCode errors.Code,
	postID store.ID,
	editorID store.ID,
	newTitle *string,
	newContents *string,
)

EditPost helps edit a post

func (AssumeFailure) EditReaction

func (notOk AssumeFailure) EditReaction(
	expectedErrorCode errors.Code,
	reactionID store.ID,
	editorID store.ID,
	newMessage string,
)

EditReaction helps edit a reaction

func (AssumeFailure) EditUser

func (notOk AssumeFailure) EditUser(
	expectedErrorCode errors.Code,
	userID store.ID,
	editorID store.ID,
	newEmail *string,
	newPassword *string,
)

EditUser helps editing a user

type AssumeSuccess

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

AssumeSuccess wraps failable helper functions

func (AssumeSuccess) Authenticate

func (ok AssumeSuccess) Authenticate(
	sessionKey string,
) *gqlmod.Session

Authenticate helps closing a session and assumes success

func (AssumeSuccess) CloseAllSessions

func (ok AssumeSuccess) CloseAllSessions(
	user store.ID,
) []string

CloseAllSessions helps closing all sessions of a user and assumes success

func (AssumeSuccess) CloseSession

func (ok AssumeSuccess) CloseSession(
	key string,
) bool

CloseSession helps closing a session and assumes success

func (AssumeSuccess) CreatePost

func (ok AssumeSuccess) CreatePost(
	authorID store.ID,
	title string,
	contents string,
) *gqlmod.Post

CreatePost helps creating a user and assumes success

func (AssumeSuccess) CreateReaction

func (ok AssumeSuccess) CreateReaction(
	author store.ID,
	subject store.ID,
	emotion emotion.Emotion,
	message string,
) *gqlmod.Reaction

CreateReaction helps creating a reaction and assumes success

func (AssumeSuccess) CreateSession

func (ok AssumeSuccess) CreateSession(
	email string,
	password string,
) *gqlmod.Session

CreateSession helps creating a new session and assumes success

func (AssumeSuccess) CreateUser

func (ok AssumeSuccess) CreateUser(
	displayName,
	email,
	password string,
) *gqlmod.User

CreateUser helps creating a user and assumes success

func (AssumeSuccess) EditPost

func (ok AssumeSuccess) EditPost(
	postID store.ID,
	editorID store.ID,
	newTitle *string,
	newContents *string,
) *gqlmod.Post

EditPost helps edit a post and assumes success

func (AssumeSuccess) EditReaction

func (ok AssumeSuccess) EditReaction(
	reactionID store.ID,
	editorID store.ID,
	newMessage string,
) *gqlmod.Reaction

EditReaction helps edit a reaction and assumes success

func (AssumeSuccess) EditUser

func (ok AssumeSuccess) EditUser(
	userID store.ID,
	editorID store.ID,
	newEmail *string,
	newPassword *string,
) *gqlmod.User

EditUser helps editing a user and assumes success

type Client

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

Client represents an API client

func (*Client) Query

func (tclt *Client) Query(
	query string,
	result interface{},
) error

Query performs an API query

func (*Client) QueryVar

func (tclt *Client) QueryVar(
	query string,
	vars map[string]interface{},
	result interface{},
) error

QueryVar performs a parameterized API query

type Helper

type Helper struct {
	OK  AssumeSuccess
	ERR AssumeFailure
	// contains filtered or unexported fields
}

Helper represents a test helper

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

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 TestContext

type TestContext struct {
	Stats   *StatisticsRecorder
	DBHost  string
	SrvHost string
}

TestContext represents a test context

type TestSetup

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

TestSetup represents the ArangoDB-based setup of an individual test

func New

func New(t *testing.T, context TestContext) *TestSetup

New creates a new test setup

func (*TestSetup) Client

func (ts *TestSetup) Client(
	email,
	password string,
) (*Client, *gqlmod.Session)

Client creates a new authenticated API client

func (*TestSetup) Debug

func (ts *TestSetup) Debug() *Client

Debug creates a new authenticated API debug client

func (*TestSetup) Guest

func (ts *TestSetup) Guest() *Client

Guest creates a new unauthenticated API client

func (*TestSetup) T

func (ts *TestSetup) T() *testing.T

T returns the test reference

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

Jump to

Keyboard shortcuts

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