testing

package
v1.1.13 Latest Latest
Warning

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

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

README

Lesser Testing Infrastructure

This package provides comprehensive testing infrastructure for the Lesser project, including integration test harness, mock services, test data factories, and performance benchmarks.

Note: This document covers the enhanced testing infrastructure. For basic Lift/DynamORM testing patterns, see the original testing guide below.

Overview

The testing infrastructure is organized into several key components:

  • Harness (harness/): Integration test utilities and API clients
  • Factories (factories/): Test data generators for consistent test data
  • Mocks (mocks/): Enhanced mock implementations for external services
  • Benchmarks (benchmarks/): Performance benchmarks for critical paths

Quick Start

Integration Testing
import (
    "github.com/equaltoai/lesser/pkg/testing/harness"
    "github.com/equaltoai/lesser/pkg/testing/factories"
)

func TestAPIIntegration(t *testing.T) {
    // Create test harness
    harness := harness.NewIntegrationTestHarness(t, nil)
    
    // Start test server with your app
    harness.StartServer(myApp)
    
    // Create test data
    actor := harness.CreateTestActor("testuser")
    
    // Make API requests
    resp := harness.MakeRequest("GET", "/users/testuser", nil, nil)
    assert.Equal(t, 200, resp.StatusCode)
}
Test Data Factories
import "github.com/equaltoai/lesser/pkg/testing/factories"

func TestWithFactories(t *testing.T) {
    // Create actor factory
    actorFactory := factories.NewActorFactory("test.example.com")
    
    // Generate test actors
    actor := actorFactory.CreateActor(factories.ActorOptions{
        Username: "testuser",
        Bot:      false,
        Locked:   false,
    })
    
    // Create timeline scenarios
    timelineFactory := factories.NewTimelineFactory("test.example.com")
    timeline := timelineFactory.CreateTimelineScenario("user", factories.MixedTimeline)
}
Benchmarking
import "github.com/equaltoai/lesser/pkg/testing/benchmarks"

func BenchmarkStorageOperations(b *testing.B) {
    storage := mocks.NewEnhancedMockStorage()
    suite := benchmarks.NewStorageBenchmarkSuite(storage)
    
    suite.Setup(b)
    suite.RunAllBenchmarks(b)
}

Components

Integration Test Harness

The integration test harness (harness/) provides:

  • IntegrationTestHarness: Complete testing environment setup
  • APIClient: HTTP client for API testing
  • MastodonAPIClient: Mastodon-specific API methods
  • ActivityPubClient: ActivityPub protocol testing
  • TestAssertions: Common test assertions

Features:

  • Automatic test data cleanup
  • Configurable storage backends (memory/DynamoDB)
  • Built-in test server management
  • Timeout and error handling
  • Comprehensive logging
Test Data Factories

The factories (factories/) provide consistent test data generation:

  • ActorFactory: Creates actors, users, bots, and locked accounts
  • ActivityFactory: Generates ActivityPub activities, notes, and interactions
  • TimelineFactory: Creates timeline scenarios for different test cases

Timeline scenarios:

  • EmptyTimeline: No content
  • SimpleTimeline: Basic posts
  • MixedTimeline: Posts, replies, boosts, likes
  • HighVolumeTimeline: Many posts for performance testing
  • ConversationTimeline: Threaded conversations
Enhanced Mock Services

The mocks (mocks/) provide sophisticated mock implementations:

  • EnhancedMockStorage: Stateful storage mock with relationship tracking
  • MockExternalService: HTTP service mock with request logging
  • MockLogger: Logger that captures log entries

Mock features:

  • Configurable latency simulation
  • Error rate simulation
  • Operation counting
  • State management
  • Request/response logging
Performance Benchmarks

The benchmarks (benchmarks/) provide performance testing for:

  • Storage operations: Create/read/update/delete performance
  • API endpoints: HTTP request/response benchmarks
  • Federation: ActivityPub protocol performance
  • Memory usage: Allocation and garbage collection
  • Concurrent access: Thread safety and scalability

CLI Commands

The repo standard is to use the lesser CLI for test workflows.

Basic testing
./lesser test
./lesser test unit
./lesser test integration
Coverage / race
./lesser test coverage
./lesser test race
Benchmarks / package-only

Use go test directly:

go test ./pkg/storage/...
go test -bench=. ./...
Load testing

See tests/README.md (k6 scripts under tests/load/ and tests/k6/).

Configuration

Test Configuration
config := &harness.TestConfig{
    Domain:        "test.example.com",
    TableName:     "test-table",
    UseMemory:     true,              // Use in-memory storage
    LogLevel:      zaptest.WarnLevel, // Reduce log noise
    ServerTimeout: 30 * time.Second,
    CleanupMode:   harness.CleanupOnSuccess, // Clean up on success only
}
Mock Configuration
storage := mocks.NewEnhancedMockStorage()
storage.SetLatencySimulation(5 * time.Millisecond) // Add 5ms latency
storage.SetErrorRate(0.01) // 1% error rate

Best Practices

Integration Tests
  1. Use the harness: Always use IntegrationTestHarness for integration tests
  2. Clean test data: Configure appropriate cleanup mode
  3. Use factories: Generate consistent test data with factories
  4. Test realistic scenarios: Use timeline scenarios that match real usage
  5. Verify behavior: Use assertions to validate expected behavior
Unit Tests
  1. Use table-driven tests: For testing multiple scenarios
  2. Mock external dependencies: Use enhanced mocks for external services
  3. Test edge cases: Include error conditions and boundary cases
  4. Keep tests fast: Use in-memory storage and minimal setup
Benchmarks
  1. Establish baselines: Record performance baselines for comparison
  2. Test realistic loads: Use scenarios that match production usage
  3. Monitor memory: Use -benchmem flag to track allocations
  4. Test concurrency: Use parallel benchmarks for concurrent access patterns
Coverage
  1. Aim for meaningful coverage: Use ./lesser test coverage and review coverage.out / coverage.html
  2. Focus on critical paths: Ensure high coverage for important functionality
  3. Don't chase 100%: Focus on meaningful tests over coverage percentage
  4. Review regularly: Use detailed coverage reports to identify gaps

Examples

See the example test files for complete usage examples:

  • harness/example_test.go: Integration testing examples
  • benchmarks/example_test.go: Benchmarking examples

Contributing

When adding new test infrastructure:

  1. Follow existing patterns: Use the established structure and naming
  2. Add documentation: Include clear documentation and examples
  3. Test your tests: Ensure test utilities work correctly
  4. Update the lesser CLI: Keep test workflows user-facing and consistent
  5. Benchmark critical paths: Add benchmarks for performance-sensitive code

Environment Variables

  • CI: Set to enable CI-specific behavior
  • INTEGRATION_TEST: Set to enable integration tests
  • TEST_ENV: Set to integration for integration test mode

Dependencies

  • testify: Assertions and testing utilities
  • zap: Logging (with zaptest for testing)
  • lift: Web framework for API testing
  • dynamorm: ORM for DynamoDB testing
  • entr: File watching (optional; use with go test in a local loop)
  • k6: Load testing tool (optional)

This testing infrastructure provides a solid foundation for maintaining code quality and performance in the Lesser project.


Original Testing Guide

The following section covers basic Lift and DynamORM testing patterns:

Key Principles

  1. Use Interface-Based Mocking: Mock at the interface level, not AWS SDK types
  2. Leverage Framework Utilities: Use Lift's TestApp and DynamORM's mocks
  3. Table-Driven Tests: Use Go's table-driven test pattern
  4. Integration Over Unit: Focus on testing complete flows

Testing Lift Handlers

Using Lift's TestApp
import lifttesting "github.com/pay-theory/lift/pkg/testing"

func TestHandler(t *testing.T) {
    // Create test app
    testApp := lifttesting.NewTestApp()
    
    // Add your handler
    testApp.App().POST("/api/endpoint", yourHandler)
    
    // Start the app
    err := testApp.Start()
    require.NoError(t, err)
    defer testApp.Stop()
    
    // Make requests
    resp := testApp.
        WithHeader("Authorization", "Bearer token").
        POST("/api/endpoint", requestBody)
    
    // Assert response
    assert.Equal(t, 200, resp.StatusCode)
}
Testing with Dependencies
func TestHandlerWithStorage(t *testing.T) {
    // Create mock storage (implements Storage interface)
    mockStorage := NewMockStorage()
    mockStorage.On("GetUser", mock.Anything, "user123").
        Return(&User{ID: "user123", Name: "Test"}, nil)
    
    // Create handler with mock
    handler := NewUserHandler(mockStorage)
    
    // Test using TestApp
    testApp := lifttesting.NewTestApp()
    testApp.App().GET("/users/:id", handler.GetUser)
    
    err := testApp.Start()
    require.NoError(t, err)
    defer testApp.Stop()
    
    resp := testApp.GET("/users/user123")
    assert.Equal(t, 200, resp.StatusCode)
    
    // Verify mock was called
    mockStorage.AssertExpectations(t)
}

Testing DynamORM Repositories

Using DynamORM Mocks
import (
    "github.com/pay-theory/dynamorm/pkg/mocks"
    lifttesting "github.com/pay-theory/lift/pkg/testing"
)

func TestRepository(t *testing.T) {
    // Option 1: Use DynamORM's MockDB
    mockDB := new(mocks.MockDB)
    mockQuery := new(mocks.MockQuery)
    
    mockDB.On("Model", mock.Anything).Return(mockQuery)
    mockQuery.On("Where", "ID", "=", "123").Return(mockQuery)
    mockQuery.On("First", mock.Anything).Return(nil)
    
    repo := NewUserRepository(mockDB)
    user, err := repo.GetByID(ctx, "123")
    
    // Option 2: Use Lift's MockDynamORM (higher level)
    mockDynamORM := lifttesting.NewMockDynamORM()
    mockDynamORM.WithData("users", map[string]any{
        "user-123": map[string]any{
            "pk": "USER#user-123",
            "sk": "USER#user-123",
            "username": "testuser",
        },
    })
    
    repo := NewUserRepository(mockDynamORM)
    user, err := repo.GetByID(ctx, "user-123")
}
Testing Transactions
func TestTransaction(t *testing.T) {
    mockDB := new(mocks.MockDB)
    
    // Mock transaction
    mockDB.On("Transaction", mock.Anything).Return(nil)
    
    repo := NewRepository(mockDB)
    err := repo.CreateWithTransaction(ctx, item)
    
    assert.NoError(t, err)
    mockDB.AssertExpectations(t)
}

Integration Testing

Testing Complete Flows
func TestCompleteStatusFlow(t *testing.T) {
    // Setup test environment
    testApp := lifttesting.NewTestApp()
    mockDynamORM := lifttesting.NewMockDynamORM()
    
    // Wire up dependencies
    storage := dynamodb.NewStorage(mockDynamORM)
    handlers := api.NewHandlers(storage)
    
    // Register routes
    testApp.App().POST("/api/v1/statuses", handlers.CreateStatus)
    testApp.App().GET("/api/v1/statuses/:id", handlers.GetStatus)
    
    err := testApp.Start()
    require.NoError(t, err)
    defer testApp.Stop()
    
    // Create status
    createResp := testApp.
        WithAuth(&lifttesting.AuthConfig{UserID: "user123"}).
        POST("/api/v1/statuses", map[string]any{
            "status": "Hello, world!",
        })
    
    assert.Equal(t, 201, createResp.StatusCode)
    
    var status Status
    err = json.Unmarshal(createResp.Body, &status)
    require.NoError(t, err)
    
    // Get status
    getResp := testApp.GET("/api/v1/statuses/" + status.ID)
    assert.Equal(t, 200, getResp.StatusCode)
}
Testing Event Handlers
func TestDynamoDBStreamHandler(t *testing.T) {
    handler := NewStreamHandler(mockStorage)
    
    // Create test event
    event := events.DynamoDBEvent{
        Records: []events.DynamoDBEventRecord{
            {
                EventName: "INSERT",
                Change: events.DynamoDBStreamRecord{
                    NewImage: map[string]events.DynamoDBAttributeValue{
                        "pk": events.NewStringAttribute("STATUS#123"),
                        "sk": events.NewStringAttribute("STATUS#123"),
                    },
                },
            },
        },
    }
    
    // Process event
    err := handler.Handle(context.Background(), event)
    assert.NoError(t, err)
}

Testing Patterns

Table-Driven Tests
func TestUserValidation(t *testing.T) {
    tests := []struct {
        name    string
        user    User
        wantErr bool
        errMsg  string
    }{
        {
            name:    "valid user",
            user:    User{Username: "valid", Email: "test@example.com"},
            wantErr: false,
        },
        {
            name:    "missing username",
            user:    User{Email: "test@example.com"},
            wantErr: true,
            errMsg:  "username required",
        },
    }
    
    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            err := ValidateUser(tt.user)
            if tt.wantErr {
                assert.Error(t, err)
                assert.Contains(t, err.Error(), tt.errMsg)
            } else {
                assert.NoError(t, err)
            }
        })
    }
}
Testing Error Cases
func TestErrorHandling(t *testing.T) {
    mockStorage := NewMockStorage()
    
    // Test various error scenarios
    t.Run("not found", func(t *testing.T) {
        mockStorage.On("GetUser", mock.Anything, "missing").
            Return(nil, storage.ErrNotFound)
        
        handler := NewUserHandler(mockStorage)
        resp := testRequest(handler, "GET", "/users/missing")
        
        assert.Equal(t, 404, resp.StatusCode)
    })
    
    t.Run("internal error", func(t *testing.T) {
        mockStorage.On("GetUser", mock.Anything, "error").
            Return(nil, errors.New("database error"))
        
        handler := NewUserHandler(mockStorage)
        resp := testRequest(handler, "GET", "/users/error")
        
        assert.Equal(t, 500, resp.StatusCode)
    })
}

Performance Testing

Using Lift's Benchmark Suite
func BenchmarkHandler(b *testing.B) {
    testApp := lifttesting.NewTestApp()
    testApp.App().POST("/api/endpoint", handler)
    
    err := testApp.Start()
    require.NoError(b, err)
    defer testApp.Stop()
    
    b.ResetTimer()
    
    for i := 0; i < b.N; i++ {
        resp := testApp.POST("/api/endpoint", testData)
        if resp.StatusCode != 200 {
            b.Fatalf("unexpected status: %d", resp.StatusCode)
        }
    }
}
Load Testing
func TestLoadScenario(t *testing.T) {
    testApp := lifttesting.NewTestApp()
    // ... setup
    
    loadTester := lifttesting.NewLoadTester(testApp, &lifttesting.LoadTestConfig{
        Duration:        30 * time.Second,
        TargetRPS:       100,
        MaxConcurrency:  10,
    })
    
    result, err := loadTester.RunLoadTest(context.Background(), func(app *lifttesting.TestApp) *lifttesting.TestResponse {
        return app.POST("/api/endpoint", testData)
    })
    
    require.NoError(t, err)
    assert.Less(t, result.ErrorRate, 0.01) // <1% errors
    assert.Less(t, result.P95Latency, 100*time.Millisecond)
}

Environment Setup

Test Environment Variables

Create a .env.test file:

# Test database
TEST_DYNAMODB_TABLE=lesser-test
AWS_REGION=us-east-1

# Test auth
JWT_SECRET=test-secret
TEST_USER_ID=test-user-123

# Feature flags
ENABLE_FEDERATION=true
ENABLE_SEARCH=true
Running Tests
# Run all tests
./lesser test

# Run specific package tests
go test ./pkg/storage/...

# Run with coverage
go test -cover ./...

# Run integration tests
./lesser test integration

# Run benchmarks
go test -bench=. ./...

Best Practices

  1. Mock at the Right Level: Mock your interfaces, not third-party libraries
  2. Use Test Fixtures: Create reusable test data builders
  3. Test Behavior, Not Implementation: Focus on what the code does, not how
  4. Clean Up: Always clean up test data and resources
  5. Parallel Tests: Use t.Parallel() where appropriate
  6. Descriptive Names: Use clear test names that describe the scenario

Common Pitfalls to Avoid

  1. Don't Mock AWS SDK Types: Use interface-based mocks instead
  2. Don't Test Framework Code: Trust that Lift and DynamORM work
  3. Don't Overuse Mocks: Sometimes integration tests are clearer
  4. Don't Ignore Errors: Always check errors in tests
  5. Don't Share State: Each test should be independent

Resources

Documentation

Overview

Package testing provides common test utilities and constants for the Lesser test suite.

Package testing provides test utilities and mock implementations for the Lesser application.

Index

Constants

View Source
const (
	// TestTableName is the default DynamoDB table name used in tests
	TestTableName = "test-table"

	// TestUsername is the default username used in tests
	TestUsername = "testuser"

	// TestDomain is the default domain used in tests
	TestDomain = "test.example.com"

	// TestActorID is the default actor ID used in tests
	TestActorID = "test-actor"

	// TestStatusID is the default status ID used in tests
	TestStatusID = "test-status"

	// TestRequestID is the default request ID used in tests
	TestRequestID = "test-request-id"
)

Test environment constants

Variables

This section is empty.

Functions

This section is empty.

Types

type MockRepositoryStorage

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

MockRepositoryStorage provides configurable repository implementations for testing. It implements the core.RepositoryStorage interface and defaults to in-memory implementations for all repositories, allowing custom mock injection via functional options.

Usage:

// Default in-memory storage
storage := testing.NewMockRepositoryStorage()

// With custom mock for specific repository
mockUserRepo := mocks.NewMockUserRepositoryInterface()
mockUserRepo.On("GetUser", mock.Anything, "testuser").Return(user, nil)
storage := testing.NewMockRepositoryStorage(
    testing.WithUserRepository(mockUserRepo),
)

func NewMockRepositoryStorage

func NewMockRepositoryStorage(opts ...Option) *MockRepositoryStorage

NewMockRepositoryStorage creates a new MockRepositoryStorage with in-memory defaults. All repositories default to in-memory implementations that can be overridden using functional options.

Example:

// Create with defaults
storage := NewMockRepositoryStorage()

// Create with custom user repository
storage := NewMockRepositoryStorage(
    WithUserRepository(customMock),
)

func (*MockRepositoryStorage) AI

AI returns the AI repository.

func (*MockRepositoryStorage) Account

Account returns the account repository.

func (*MockRepositoryStorage) Activity

Activity returns the activity repository (interface type for mockability).

func (*MockRepositoryStorage) Actor

Actor returns the actor repository (interface type for mockability).

func (*MockRepositoryStorage) Analytics

Analytics returns the analytics/trending repository.

func (*MockRepositoryStorage) Announcement

Announcement returns the announcement repository.

func (*MockRepositoryStorage) Article

Article returns the article repository (interface type for mockability).

func (*MockRepositoryStorage) Audit

Audit returns the audit repository.

func (*MockRepositoryStorage) Bookmark

Bookmark returns the bookmark repository.

func (*MockRepositoryStorage) Category

Category returns the category repository (interface type for mockability).

func (*MockRepositoryStorage) CloudWatchMetrics

CloudWatchMetrics returns the CloudWatch metrics repository.

func (*MockRepositoryStorage) CommunityNote

CommunityNote returns the community note repository.

func (*MockRepositoryStorage) Conversation

Conversation returns the conversation repository.

func (*MockRepositoryStorage) Cost

Cost returns the cost tracking repository.

func (*MockRepositoryStorage) DLQ

DLQ returns the DLQ repository.

func (*MockRepositoryStorage) DNSCache

DNSCache returns the DNS cache repository.

func (*MockRepositoryStorage) DomainBlock

DomainBlock returns the domain block repository.

func (*MockRepositoryStorage) Draft

Draft returns the draft repository (interface type for mockability).

func (*MockRepositoryStorage) Emoji

Emoji returns the emoji repository.

func (*MockRepositoryStorage) Export

Export returns the export repository.

func (*MockRepositoryStorage) FeaturedTag

FeaturedTag returns the featured tag repository.

func (*MockRepositoryStorage) Federation

Federation returns the federation repository.

func (*MockRepositoryStorage) Filter

Filter returns the filter repository.

func (*MockRepositoryStorage) GetDB

GetDB returns nil for mock storage (no real database connection).

func (*MockRepositoryStorage) GetLogger

func (s *MockRepositoryStorage) GetLogger() *zap.Logger

GetLogger returns the configured logger.

func (*MockRepositoryStorage) GetTableName

func (s *MockRepositoryStorage) GetTableName() string

GetTableName returns the configured table name.

func (*MockRepositoryStorage) Hashtag

Hashtag returns the hashtag repository.

func (*MockRepositoryStorage) Import

Import returns the import repository.

func (*MockRepositoryStorage) Instance

Instance returns the instance repository.

func (*MockRepositoryStorage) Like

Like returns the like repository.

func (*MockRepositoryStorage) List

List returns the list repository.

func (*MockRepositoryStorage) Marker

Marker returns the marker repository.

func (*MockRepositoryStorage) Media

Media returns the media repository.

func (*MockRepositoryStorage) MediaAnalytics

MediaAnalytics returns the media analytics repository.

func (*MockRepositoryStorage) MediaMetadata

MediaMetadata returns the media metadata repository.

func (*MockRepositoryStorage) MediaPopularity

MediaPopularity returns the media popularity repository.

func (*MockRepositoryStorage) MediaSession

MediaSession returns the media session repository.

func (*MockRepositoryStorage) MetricRecord

MetricRecord returns the metric record repository.

func (*MockRepositoryStorage) Moderation

Moderation returns the moderation repository (interface type for mockability).

func (*MockRepositoryStorage) ModerationML

ModerationML returns the moderation ML repository.

func (*MockRepositoryStorage) Notification

Notification returns the notification repository (interface type for mockability).

func (*MockRepositoryStorage) OAuth

OAuth returns the OAuth repository.

func (*MockRepositoryStorage) Object

Object returns the object repository (interface type for mockability).

func (*MockRepositoryStorage) Poll

Poll returns the poll repository.

func (*MockRepositoryStorage) Publication

Publication returns the publication repository (interface type for mockability).

func (*MockRepositoryStorage) PublicationMember

PublicationMember returns the publication member repository (interface type for mockability).

func (*MockRepositoryStorage) PushSubscription

PushSubscription returns the push subscription repository.

func (*MockRepositoryStorage) Quote

Quote returns the quote repository.

func (*MockRepositoryStorage) RateLimit

RateLimit returns the rate limit repository.

func (*MockRepositoryStorage) Recovery

Recovery returns the recovery repository.

func (*MockRepositoryStorage) Relationship

Relationship returns the relationship repository.

func (*MockRepositoryStorage) Relay

Relay returns the relay repository.

func (*MockRepositoryStorage) Revision

Revision returns the revision repository (interface type for mockability).

func (*MockRepositoryStorage) ScheduledStatus

ScheduledStatus returns the scheduled status repository.

func (*MockRepositoryStorage) Search

Search returns the search repository.

func (*MockRepositoryStorage) Series

Series returns the series repository (interface type for mockability).

func (*MockRepositoryStorage) Severance

Severance returns the severance repository.

func (*MockRepositoryStorage) Social

Social returns the social repository.

func (*MockRepositoryStorage) Status

Status returns the status repository (interface type for mockability).

func (*MockRepositoryStorage) StreamingCloudWatch

StreamingCloudWatch returns the streaming CloudWatch repository.

func (*MockRepositoryStorage) StreamingConnection

StreamingConnection returns the streaming connection repository.

func (*MockRepositoryStorage) Thread

Thread returns the thread repository.

func (*MockRepositoryStorage) Timeline

Timeline returns the timeline repository (interface type for mockability).

func (*MockRepositoryStorage) Trust

Trust returns the trust repository (interface type for mockability).

func (*MockRepositoryStorage) User

User returns the user repository (interface type for mockability).

func (*MockRepositoryStorage) WebSocketCost

WebSocketCost returns the WebSocket cost repository.

type Option

type Option func(*MockRepositoryStorage)

Option configures MockRepositoryStorage

func WithActivityRepository

func WithActivityRepository(repo interfaces.ActivityRepository) Option

WithActivityRepository sets a custom activity repository implementation. Use this to inject a mock for testing specific activity repository behavior.

func WithActorRepository

func WithActorRepository(repo interfaces.ActorRepository) Option

WithActorRepository sets a custom actor repository implementation. Use this to inject a mock for testing specific actor repository behavior.

func WithArticleRepository

func WithArticleRepository(repo interfaces.ArticleRepository) Option

WithArticleRepository sets a custom article repository implementation. Use this to inject a mock for testing specific article repository behavior.

func WithCategoryRepository

func WithCategoryRepository(repo interfaces.CategoryRepository) Option

WithCategoryRepository sets a custom category repository implementation. Use this to inject a mock for testing specific category repository behavior.

func WithDraftRepository

func WithDraftRepository(repo interfaces.DraftRepository) Option

WithDraftRepository sets a custom draft repository implementation. Use this to inject a mock for testing specific draft repository behavior.

func WithLogger

func WithLogger(logger *zap.Logger) Option

WithLogger sets a custom logger for the mock storage.

func WithMediaAnalyticsRepository

func WithMediaAnalyticsRepository(repo interfaces.MediaAnalyticsRepository) Option

WithMediaAnalyticsRepository sets a custom media analytics repository implementation. Use this to inject a mock for testing specific media analytics repository behavior.

func WithMediaPopularityRepository

func WithMediaPopularityRepository(repo interfaces.MediaPopularityRepository) Option

WithMediaPopularityRepository sets a custom media popularity repository implementation. Use this to inject a mock for testing specific media popularity repository behavior.

func WithMediaSessionRepository

func WithMediaSessionRepository(repo interfaces.MediaSessionRepository) Option

WithMediaSessionRepository sets a custom media session repository implementation. Use this to inject a mock for testing specific media session repository behavior.

func WithModerationRepository

func WithModerationRepository(repo interfaces.ModerationRepository) Option

WithModerationRepository sets a custom moderation repository implementation. Use this to inject a mock for testing specific moderation repository behavior.

func WithPublicationMemberRepository

func WithPublicationMemberRepository(repo interfaces.PublicationMemberRepository) Option

WithPublicationMemberRepository sets a custom publication member repository implementation. Use this to inject a mock for testing specific publication member repository behavior.

func WithPublicationRepository

func WithPublicationRepository(repo interfaces.PublicationRepository) Option

WithPublicationRepository sets a custom publication repository implementation. Use this to inject a mock for testing specific publication repository behavior.

func WithRevisionRepository

func WithRevisionRepository(repo interfaces.RevisionRepository) Option

WithRevisionRepository sets a custom revision repository implementation. Use this to inject a mock for testing specific revision repository behavior.

func WithSeriesRepository

func WithSeriesRepository(repo interfaces.SeriesRepository) Option

WithSeriesRepository sets a custom series repository implementation. Use this to inject a mock for testing specific series repository behavior.

func WithStatusRepository

func WithStatusRepository(repo interfaces.StatusRepository) Option

WithStatusRepository sets a custom status repository implementation. Use this to inject a mock for testing specific status repository behavior.

func WithStreamingConnectionRepository

func WithStreamingConnectionRepository(repo interfaces.StreamingConnectionRepository) Option

WithStreamingConnectionRepository sets a custom streaming connection repository implementation. Use this to inject a mock for testing specific streaming connection repository behavior.

func WithTableName

func WithTableName(tableName string) Option

WithTableName sets a custom table name for the mock storage.

func WithTimelineRepository

func WithTimelineRepository(repo interfaces.TimelineRepository) Option

WithTimelineRepository sets a custom timeline repository implementation. Use this to inject a mock for testing specific timeline repository behavior.

func WithTrustRepository

func WithTrustRepository(repo interfaces.TrustRepository) Option

WithTrustRepository sets a custom trust repository implementation. Use this to inject a mock for testing specific trust repository behavior.

func WithUserRepository

func WithUserRepository(repo interfaces.UserRepository) Option

WithUserRepository sets a custom user repository implementation. Use this to inject a mock for testing specific user repository behavior.

Directories

Path Synopsis
Package benchmarks provides API performance benchmarks
Package benchmarks provides API performance benchmarks
Package cost provides comprehensive cost analysis testing utilities for AWS service usage validation.
Package cost provides comprehensive cost analysis testing utilities for AWS service usage validation.
Package factories provides test data factories for consistent test data generation
Package factories provides test data factories for consistent test data generation
Package harness provides API client utilities for integration testing
Package harness provides API client utilities for integration testing
Package inmemory provides thread-safe in-memory implementations of repository interfaces.
Package inmemory provides thread-safe in-memory implementations of repository interfaces.
Package integration provides end-to-end Lambda function testing utilities and test case management.
Package integration provides end-to-end Lambda function testing utilities and test case management.
Package mocks provides mock implementations for testing.
Package mocks provides mock implementations for testing.
Package theorydb provides test utilities for validating TheoryDB/DynamORM-backed repositories.
Package theorydb provides test utilities for validating TheoryDB/DynamORM-backed repositories.

Jump to

Keyboard shortcuts

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