testhelpers

package
v0.0.0-...-364598c Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CurrentUserID = "auth0|61916c1dab79c900713936de"
	StudySlug     = "test-study"
	TestOrgID     = "fda19390-d1e7-4893-a13a-d14c88cc737b"
)
View Source
const StudyID = "92b322df-9dac-4240-a88e-d3aa715be83d"

Variables

This section is empty.

Functions

func CreateAccounts

func CreateAccounts(t *testing.T, a types.Account, created time.Time) error

func CreateDatabaseStudyConf

func CreateDatabaseStudyConf(t *testing.T, dsc types.DatabaseStudyConf) error

func CreateSegment

func CreateSegment(t *testing.T, sp []types.SegmentsProgress) error

func CreateStudy

func CreateStudy(t *testing.T, slug, userID string) error

func CreateStudyFromStudy

func CreateStudyFromStudy(t *testing.T, study types.Study) error

func CreateUser

func CreateUser(t *testing.T)

func DeleteAllAccounts

func DeleteAllAccounts(t *testing.T)

func DeleteAllStudies

func DeleteAllStudies(t *testing.T)

func DeleteAllStudyConfs

func DeleteAllStudyConfs(t *testing.T)

DeleteAllStudyConfs Helper function that clears the study_confs table

func DeleteAllStudySegments

func DeleteAllStudySegments(t *testing.T)

func DeleteAllUsers

func DeleteAllUsers(t *testing.T)

func FakeValidTokenMiddleware

func FakeValidTokenMiddleware(userID string) gin.HandlerFunc

func GetFBSession

func GetFBSession() (
	session *fb.Session,
	teardown func(),
)

GetFBSession Returns a Mock Server in order to mock facebook

func GetFBTestApp

func GetFBTestApp() (
	a *fb.App,
	teardown func(),
)

func GetRepositories

func GetRepositories() storage.Repositories

TODO this depends on a package that we want to test using the testhelper, we should remove alle dependencies in this helper to avoid circular dependency errors

func NewDatabaseStudyConf

func NewDatabaseStudyConf(opts ...databasestudyconfoptions) *types.DatabaseStudyConf

func NewStudyConf

func NewStudyConf(opts ...studyconfigoptions) types.StudyConf

NewStudyConf is a test helper that generates a studyconf with some sensible defaults and allows for overrides, please make use of this in tests as this structure might change and it will be easier to update this in a single place.

example: return full studyConfig

sc := NewStudyConf()

example: set one of the confs to nil

sc := NewStudyConf(WithTargetingConf(nil))

example: override one of the confs (you need to pass in all fields of specified conf)

general := &types.GeneralConf{ Name: "bar", etc...}

sc := NewStudyConf(WithGeneralConf(general))

func TypeAudiences

func TypeAudiences() databasestudyconfoptions

func TypeCreatives

func TypeCreatives() databasestudyconfoptions

func TypeDestinations

func TypeDestinations() databasestudyconfoptions

func TypeGeneral

func TypeGeneral() databasestudyconfoptions

func TypeRecruitment

func TypeRecruitment() databasestudyconfoptions

func TypeStrata

func TypeStrata() databasestudyconfoptions

func TypeVariables

func TypeVariables() databasestudyconfoptions

func WithAudiences

func WithAudiences(as []*types.AudienceConf) studyconfigoptions

WithAudiences is used to override the default AudienceConf

func WithDestinationConf

func WithDestinationConf(d *types.DestinationConf) studyconfigoptions

WithDestinationConf is used to override the default DestinationConf

func WithGeneralConf

func WithGeneralConf(g *types.GeneralConf) studyconfigoptions

WithGeneralConf is used to override the default GeneralConf

func WithRecruitmentConf

func WithRecruitmentConf(r *types.RecruitmentConf) studyconfigoptions

WithRecruitmentConf is used to override the default RecruitmentConf

func WithStratumConf

func WithStratumConf(s []*types.StratumConf) studyconfigoptions

WithStratumConf is used to override the default StrataConf

func WithVariables

func WithVariables(as []*types.VariableConf) studyconfigoptions

Types

type Response

type Response struct {
	StatusCode int
	Header     http.Header
	Body       string
}

func PerformDeleteRequest

func PerformDeleteRequest(
	path, userID string,
	repositories storage.Repositories,
	body interface{},
) Response

func PerformGetRequest

func PerformGetRequest(path string, repositories storage.Repositories) Response

func PerformPostRequest

func PerformPostRequest(
	path, userID string,
	repositories storage.Repositories,
	body interface{},
) Response

func PerformRequest

func PerformRequest(
	path, userID string,
	method string,
	repositories storage.Repositories,
	body interface{},
) Response

Jump to

Keyboard shortcuts

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