testhelpers

package
v0.85.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IntegrationTestsEnabled

func IntegrationTestsEnabled() bool

We use an env variable because testing flags will require us to add them to each testing package

func NewConfData added in v0.60.0

func NewConfData(db *TestDatabase, t *testing.T) *conf.Data

Types

type NewTestingUCOpt

type NewTestingUCOpt func(*newTestingOpts)

func WithCredsReaderWriter

func WithCredsReaderWriter(rw credentials.ReaderWriter) NewTestingUCOpt

func WithRegisteredIntegration added in v0.11.1

func WithRegisteredIntegration(i sdk.FanOut) NewTestingUCOpt

type TestDatabase

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

func NewTestDatabase

func NewTestDatabase(t *testing.T) *TestDatabase

func (*TestDatabase) Close

func (db *TestDatabase) Close(t *testing.T)

func (*TestDatabase) ConnectionString

func (db *TestDatabase) ConnectionString(t *testing.T) string

func (*TestDatabase) Port

func (db *TestDatabase) Port(t *testing.T) int

type TestingRepos added in v0.40.0

type TestingRepos struct {
	Membership       biz.MembershipRepo
	Referrer         biz.ReferrerRepo
	Workflow         biz.WorkflowRepo
	WorkflowRunRepo  biz.WorkflowRunRepo
	AttestationState biz.AttestationStateRepo
}

type TestingUseCases

type TestingUseCases struct {
	// Misc
	DB   *TestDatabase
	Data *data.Data
	L    log.Logger

	// Use cases
	Membership             *biz.MembershipUseCase
	CASBackend             *biz.CASBackendUseCase
	Integration            *biz.IntegrationUseCase
	Organization           *biz.OrganizationUseCase
	WorkflowContract       *biz.WorkflowContractUseCase
	Workflow               *biz.WorkflowUseCase
	WorkflowRun            *biz.WorkflowRunUseCase
	User                   *biz.UserUseCase
	RobotAccount           *biz.RobotAccountUseCase
	RegisteredIntegrations sdk.AvailablePlugins
	CASMapping             *biz.CASMappingUseCase
	OrgInvitation          *biz.OrgInvitationUseCase
	Referrer               *biz.ReferrerUseCase
	APIToken               *biz.APITokenUseCase
	Enforcer               *authz.Enforcer
	AttestationState       *biz.AttestationStateUseCase
	// Repositories that can be used for custom crafting of use-cases
	Repos *TestingRepos
}

TestingUseCases holds all the test data that can be used in the different suites NOTE: It connects to a real database

func NewTestingUseCases

func NewTestingUseCases(t *testing.T, opts ...NewTestingUCOpt) *TestingUseCases

func WireTestData

func WireTestData(testDatabase *TestDatabase, t *testing.T, logger log.Logger, readerWriter credentials.ReaderWriter, builder *robotaccount.Builder, auth *conf.Auth, availablePlugins sdk.AvailablePlugins, providers backend.Providers) (*TestingUseCases, func(), error)

wireTestData init testing data

type UseCasesEachTestSuite

type UseCasesEachTestSuite struct {
	suite.Suite
	*TestingUseCases
}

Suite that creates a database and sets the schema before each test

func (*UseCasesEachTestSuite) SetupSuite

func (s *UseCasesEachTestSuite) SetupSuite()

Run only if the integration flag is set

func (*UseCasesEachTestSuite) SetupTest

func (s *UseCasesEachTestSuite) SetupTest()

Run before each test

func (*UseCasesEachTestSuite) TearDownTest

func (s *UseCasesEachTestSuite) TearDownTest()

Run after each test

Jump to

Keyboard shortcuts

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