frametests

package
v2.1.8 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFreePort

func GetFreePort(ctx context.Context) (int, error)

func WaitForCheckedConditionWithResult

func WaitForCheckedConditionWithResult[T any](
	ctx context.Context,
	condition func() (*T, error), canReturnChecker func(*T, error) bool,
	timeout time.Duration,
	pollInterval time.Duration,
) (*T, error)

WaitForCheckedConditionWithResult polls a condition function until it returns a non-nil result or timeout occurs This is useful when you need to wait for a specific result from an operation.

func WaitForConditionWithResult

func WaitForConditionWithResult[T any](
	ctx context.Context,
	condition func() (*T, error),
	timeout time.Duration,
	pollInterval time.Duration,
) (*T, error)

WaitForConditionWithResult polls a condition function until it returns a non-nil result or timeout occurs This is useful when you need to wait for a specific result from an operation.

func WithBoundHTTPTestDriver added in v2.1.7

func WithBoundHTTPTestDriver() (frame.Option, func() *httptest.Server)

WithBoundHTTPTestDriver is WithHTTPTestDriver bound to the service's configured HTTP port (HTTPServerPort) instead of a random one. Use it when peers such as an OAuth2 server or webhook caller are configured with the service URL before the service starts. Service.Run returns once the listener is bound, so startup and listen errors surface synchronously — no goroutine or readiness polling needed.

func WithHTTPTestDriver

func WithHTTPTestDriver() (frame.Option, func() *httptest.Server)

WithHTTPTestDriver uses a driver, mostly useful when writing tests against the frame service. The server listens on a random loopback port; read it from the returned accessor.

func WithNoopDriver

func WithNoopDriver() frame.Option

WithNoopDriver uses a no-op driver, mostly useful when writing tests against the frame service.

func WithTestDependencies

func WithTestDependencies(t *testing.T,
	options []*definition.DependencyOption,
	testFn func(t *testing.T, opt *definition.DependencyOption))

WithTestDependencies runs subtests for each provided DependencyOption. It ensures each subtest is properly isolated and runs in parallel if desired.

Types

type FrameBaseTestSuite

type FrameBaseTestSuite struct {
	suite.Suite
	Network *testcontainers.DockerNetwork

	InitResourceFunc func(ctx context.Context) []definition.TestResource
	// contains filtered or unexported fields
}

FrameBaseTestSuite provides a base test suite with all necessary test components.

func (*FrameBaseTestSuite) Resources

func (s *FrameBaseTestSuite) Resources() []definition.DependancyConn

func (*FrameBaseTestSuite) SeedPartitionInheritance

func (s *FrameBaseTestSuite) SeedPartitionInheritance(
	ctx context.Context,
	auth security.Authorizer,
	tenancyAccessNamespace, tenantID, parentPartitionID, childPartitionID string,
)

SeedPartitionInheritance links a child partition to a parent so that members (or services) of the parent automatically inherit access to the child. The reverse does NOT hold — child members cannot access the parent.

func (*FrameBaseTestSuite) SeedTenantAccess

func (s *FrameBaseTestSuite) SeedTenantAccess(
	ctx context.Context,
	auth security.Authorizer,
	tenancyAccessNamespace, tenantID, partitionID, profileID string,
)

SeedTenantAccess writes a tenancy_access member tuple so the profile can pass the TenancyAccessChecker (data access layer). The tenancyAccessNamespace is typically "tenancy_access".

func (*FrameBaseTestSuite) SetupSuite

func (s *FrameBaseTestSuite) SetupSuite()

SetupSuite initialises the test environment for the test suite.

func (*FrameBaseTestSuite) TearDownSuite

func (s *FrameBaseTestSuite) TearDownSuite()

TearDownSuite cleans up resources after all tests are completed.

func (*FrameBaseTestSuite) WithAuthClaims

func (s *FrameBaseTestSuite) WithAuthClaims(
	ctx context.Context,
	tenantID, partitionID, profileID string,
) context.Context

WithAuthClaims creates a context with fully populated authentication claims for test scenarios that require tenant-scoped operations.

Directories

Path Synopsis
deps
Package rlstest provides a test-only tenancy.Provider wrapper that drops connections to an unprivileged role so Postgres FORCE ROW LEVEL SECURITY is actually enforced.
Package rlstest provides a test-only tenancy.Provider wrapper that drops connections to an unprivileged role so Postgres FORCE ROW LEVEL SECURITY is actually enforced.
rpcservice

Jump to

Keyboard shortcuts

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