testhelpers

package
v0.0.0-...-66c7a0d Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMockPolicyRefresher

func NewMockPolicyRefresher() server.PolicyRefresher

func NewMockProjectPurger

func NewMockProjectPurger(gyComplete bool) *mockProjectPurger

func NewMockProjectUpdateManager

func NewMockProjectUpdateManager() *mockProjectUpdateManager

func WaitForWithTimeout

func WaitForWithTimeout(t *testing.T, f func() bool, timeout time.Duration, message string)

Types

type MockEventServiceClient

type MockEventServiceClient struct {
	PublishedEvents       int
	LastestPublishedEvent *automate_event.EventMsg
}

func (*MockEventServiceClient) Publish

func (*MockEventServiceClient) Start

func (*MockEventServiceClient) Stop

func (*MockEventServiceClient) Subscribe

type TestDB

type TestDB struct {
	*sql.DB
	ConnURI string
}

func SetupProjectsAndRulesWithDB

func SetupProjectsAndRulesWithDB(t *testing.T) (
	api.ProjectsServiceClient, api.PoliciesServiceClient, *TestDB, storage.Storage, int64)

SetupProjectsAndRulesWithDB is a simplified test framework useful for integration tests with just the DB.

func SetupTestDB

func SetupTestDB(t *testing.T) (storage.Storage, *TestDB, *opa.State, *prng.Prng, *migration.Config)

func SetupTestDBWithLimit

func SetupTestDBWithLimit(t *testing.T, projectLimit int) (storage.Storage, *TestDB, *opa.State, *prng.Prng, *migration.Config)

func (*TestDB) CloseDB

func (d *TestDB) CloseDB(t *testing.T)

func (*TestDB) Flush

func (d *TestDB) Flush(t *testing.T)

type TestFramework

type TestFramework struct {
	Policy               api.PoliciesServiceClient
	Authz                api.AuthorizationServiceClient
	Projects             api.ProjectsServiceClient
	TestDB               *TestDB
	Engine               engine.Engine
	Seed                 int64
	PolicyRefresher      server.PolicyRefresher
	GRPC                 *grpctest.Server
	ProjectUpdateManager server.ProjectUpdateMgr
}

func (*TestFramework) Shutdown

func (tf *TestFramework) Shutdown(t *testing.T, ctx context.Context)

Shutdown must be called at the end of every test that uses TestFramework otherwise strange things might happen with the authz-service/config.Manager because other tests might accidentally get state to its config file if we don't kill the goroutine that writes to it.

Jump to

Keyboard shortcuts

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