Documentation
¶
Overview ¶
Package theorydb provides test utilities for validating TheoryDB/DynamORM-backed repositories.
Index ¶
- func AssertEventualConsistency(t *testing.T, checkFunc func() (bool, error), timeout time.Duration)
- func BenchmarkRepository(b *testing.B, operation func())
- func BuildTestActor(id string) *models.Actor
- func BuildTestStatus(id, authorID string) *models.Status
- func BuildTestTimeline(actorID, statusID string) *models.Timeline
- func TestConcurrentOperations(t *testing.T, operations []func() error, _ int)
- func TestCreate(t *testing.T, createFunc func(context.Context, interface{}) error, ...)
- func TestDelete(t *testing.T, deleteFunc func(context.Context, string) error, id string)
- func TestGet(t *testing.T, getFunc func(context.Context, string) (interface{}, error), ...)
- func TestQuery(t *testing.T, ...)
- func TestTransaction(t *testing.T, txFunc func(context.Context, func(core.Tx) error) error)
- func TestUpdate(t *testing.T, updateFunc func(context.Context, interface{}) error, ...)
- type MockCostTracker
- type RepositoryTestCase
- type RepositoryTestSuite
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertEventualConsistency ¶
AssertEventualConsistency tests eventual consistency scenarios
func BenchmarkRepository ¶
BenchmarkRepository benchmarks repository operations
func BuildTestActor ¶
BuildTestActor creates a test actor for repository testing
func BuildTestStatus ¶
BuildTestStatus creates a test status for repository testing
func BuildTestTimeline ¶
BuildTestTimeline creates a test timeline entry
func TestConcurrentOperations ¶
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 ¶
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 ¶
TestTransaction tests repository transaction 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