testhelpers

package
v1.50.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: Apache-2.0 Imports: 28 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 NewCASBackendConfig added in v0.140.0

func NewCASBackendConfig() *conf.Bootstrap_CASServer

func NewCASServerOptions added in v0.146.0

func NewCASServerOptions(in *conf.Bootstrap_CASServer) *biz.CASServerDefaultOpts

func NewConfData

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

func NewDataConfig

func NewDataConfig(in *conf.Data) *config.DatabaseConfig

func NewPolicyProviderConfig added in v0.96.1

func NewPolicyProviderConfig(in *conf.Bootstrap) []*policies.NewRegistryConfig

func NewPromSpec added in v0.95.0

func NewPromSpec() []*conf.PrometheusIntegrationSpec

Types

type NewTestingUCOpt

type NewTestingUCOpt func(*newTestingOpts)

func WithBackendProviders added in v1.43.4

func WithBackendProviders(providers backends.Providers) NewTestingUCOpt

func WithCredsReaderWriter

func WithCredsReaderWriter(rw credentials.ReaderWriter) NewTestingUCOpt

func WithOnboardingConfiguration added in v0.91.8

func WithOnboardingConfiguration(conf []*config.OnboardingSpec) NewTestingUCOpt

func WithRegisteredIntegration

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

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

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
	Prometheus             *biz.PrometheusUseCase
	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
	ProjectVersion         *biz.ProjectVersionUseCase
	Project                *biz.ProjectUseCase
	OrgMetrics             *biz.OrgMetricsUseCase
	Group                  *biz.GroupUseCase
	// 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, bootstrap *conf.Bootstrap, arg []*v1.OnboardingSpec, 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