theorydb

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package theorydb provides test utilities for validating TheoryDB/DynamORM-backed repositories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertEventualConsistency

func AssertEventualConsistency(t *testing.T, checkFunc func() (bool, error), timeout time.Duration)

AssertEventualConsistency tests eventual consistency scenarios

func BenchmarkRepository

func BenchmarkRepository(b *testing.B, operation func())

BenchmarkRepository benchmarks repository operations

func BuildTestActor

func BuildTestActor(id string) *models.Actor

BuildTestActor creates a test actor for repository testing

func BuildTestStatus

func BuildTestStatus(id, authorID string) *models.Status

BuildTestStatus creates a test status for repository testing

func BuildTestTimeline

func BuildTestTimeline(actorID, statusID string) *models.Timeline

BuildTestTimeline creates a test timeline entry

func TestConcurrentOperations

func TestConcurrentOperations(t *testing.T, operations []func() error, _ int)

TestConcurrentOperations tests concurrent repository operations

func TestCreate

func TestCreate(t *testing.T, createFunc func(context.Context, interface{}) error, item interface{})

TestCreate tests repository Create operations

func TestDelete

func TestDelete(t *testing.T, deleteFunc func(context.Context, string) error, id string)

TestDelete tests repository Delete operations

func TestGet

func TestGet(t *testing.T, getFunc func(context.Context, string) (interface{}, error), id string, expectedItem interface{})

TestGet tests repository Get operations

func TestQuery

func TestQuery(t *testing.T, queryFunc func(context.Context, string, int, string) ([]interface{}, string, error))

TestQuery tests repository Query operations

func TestTransaction

func TestTransaction(t *testing.T, txFunc func(context.Context, func(core.Tx) error) error)

TestTransaction tests repository transaction operations

func TestUpdate

func TestUpdate(t *testing.T, updateFunc func(context.Context, interface{}) error, item interface{})

TestUpdate tests repository Update operations

Types

type MockCostTracker

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

MockCostTracker tracks DynamoDB operation costs in tests

func NewMockCostTracker

func NewMockCostTracker() *MockCostTracker

NewMockCostTracker creates a new cost tracker

func (*MockCostTracker) AssertCostWithinBudget

func (m *MockCostTracker) AssertCostWithinBudget(t *testing.T, maxRCU, maxWCU float64)

AssertCostWithinBudget verifies operations stay within cost budget

func (*MockCostTracker) GetTotalCost

func (m *MockCostTracker) GetTotalCost() (rcu, wcu float64)

GetTotalCost returns total consumed capacity

func (*MockCostTracker) TrackOperation

func (m *MockCostTracker) TrackOperation(operation string, rcu, wcu float64)

TrackOperation records an operation

type RepositoryTestCase

type RepositoryTestCase struct {
	Name         string
	SetupFunc    func(*mocks.MockDB)
	TestFunc     func(context.Context) error
	ExpectError  bool
	ErrorMsg     string
	ValidateFunc func(*testing.T, *mocks.MockDB)
}

RepositoryTestCase defines a test case for repository testing

type RepositoryTestSuite

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

RepositoryTestSuite provides utilities for testing DynamORM repositories

func NewRepositoryTestSuite

func NewRepositoryTestSuite(t *testing.T) *RepositoryTestSuite

NewRepositoryTestSuite creates a new repository test suite

func (*RepositoryTestSuite) GetMockDB

func (s *RepositoryTestSuite) GetMockDB() *mocks.MockDB

GetMockDB returns the mock database

func (*RepositoryTestSuite) RunTest

func (s *RepositoryTestSuite) RunTest(tc RepositoryTestCase)

RunTest executes a repository test case

Jump to

Keyboard shortcuts

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