testhelpers

package
v0.0.0-...-d3ca574 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CurrentUserId = "auth0|61916c1dab79c900713936de"
	StudySlug     = "test-study"
)
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 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

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 TypeTargeting

func TypeTargeting() databasestudyconfoptions

func TypeTargetingDistribution

func TypeTargetingDistribution() 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 WithTargetingConf

func WithTargetingConf(t *types.TargetingConf) studyconfigoptions

WithTargetingConf is used to overide the default TargetingConf

func WithTargetingDistributionConf

func WithTargetingDistributionConf(
	t *types.TargetingDistributionConf,
) studyconfigoptions

WithTargetingDistributionConf is used to override the default TargetingDistributionConf

Types

type Response

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

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