testutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckEnvironmentFilter

func CheckEnvironmentFilter(ctx context.Context, itemEnvID string) bool

CheckEnvironmentFilter is a helper function to check if an item matches the environment filter

func NewInMemoryEventPublisher

func NewInMemoryEventPublisher(eventStore *InMemoryEventStore) publisher.EventPublisher

NewInMemoryEventPublisher creates a new instance of InMemoryPublisherService

func NewMockPostgresClient

func NewMockPostgresClient(logger *logger.Logger) postgres.IClient

NewMockPostgresClient creates a new mock postgres client

func SetupContext

func SetupContext() context.Context

Types

type BaseServiceTestSuite

type BaseServiceTestSuite struct {
	suite.Suite
	// contains filtered or unexported fields
}

BaseServiceTestSuite provides common functionality for all service test suites

func (*BaseServiceTestSuite) ClearStores

func (s *BaseServiceTestSuite) ClearStores()

func (*BaseServiceTestSuite) GetConfig

func (s *BaseServiceTestSuite) GetConfig() *config.Configuration

GetConfig returns the test configuration

func (*BaseServiceTestSuite) GetContext

func (s *BaseServiceTestSuite) GetContext() context.Context

GetContext returns the test context

func (*BaseServiceTestSuite) GetDB

GetDB returns the test database client

func (*BaseServiceTestSuite) GetLogger

func (s *BaseServiceTestSuite) GetLogger() *logger.Logger

GetLogger returns the test logger

func (*BaseServiceTestSuite) GetNow

func (s *BaseServiceTestSuite) GetNow() time.Time

GetNow returns the current test time

func (*BaseServiceTestSuite) GetPublisher

func (s *BaseServiceTestSuite) GetPublisher() publisher.EventPublisher

GetPublisher returns the test event publisher

func (*BaseServiceTestSuite) GetStores

func (s *BaseServiceTestSuite) GetStores() Stores

GetStores returns all test repositories

func (*BaseServiceTestSuite) GetUUID

func (s *BaseServiceTestSuite) GetUUID() string

GetUUID returns a new UUID string

func (*BaseServiceTestSuite) GetWebhookPublisher

func (s *BaseServiceTestSuite) GetWebhookPublisher() webhookPublisher.WebhookPublisher

GetWebhookPublisher returns the test webhook publisher

func (*BaseServiceTestSuite) SetupSuite

func (s *BaseServiceTestSuite) SetupSuite()

SetupSuite is called once before running the tests in the suite

func (*BaseServiceTestSuite) SetupTest

func (s *BaseServiceTestSuite) SetupTest()

SetupTest is called before each test

func (*BaseServiceTestSuite) TearDownTest

func (s *BaseServiceTestSuite) TearDownTest()

TearDownTest is called after each test

type FilterFunc

type FilterFunc[T any] func(ctx context.Context, item T, filter interface{}) bool

FilterFunc is a generic filter function type

type InMemoryAuthRepository

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

InMemoryAuthRepository is an in-memory implementation of the auth.Repository interface

func NewInMemoryAuthRepository

func NewInMemoryAuthRepository() *InMemoryAuthRepository

NewInMemoryAuthRepository creates a new instance of InMemoryAuthRepository

func (*InMemoryAuthRepository) Clear

func (r *InMemoryAuthRepository) Clear()

Clear clears all auth records from the in-memory store

func (*InMemoryAuthRepository) CreateAuth

func (r *InMemoryAuthRepository) CreateAuth(ctx context.Context, auth *auth.Auth) error

CreateAuth creates a new auth record in the in-memory store

func (*InMemoryAuthRepository) DeleteAuth

func (r *InMemoryAuthRepository) DeleteAuth(ctx context.Context, userID string) error

DeleteAuth deletes an auth record by user ID from the in-memory store

func (*InMemoryAuthRepository) GetAuthByUserID

func (r *InMemoryAuthRepository) GetAuthByUserID(ctx context.Context, userID string) (*auth.Auth, error)

GetAuthByUserID retrieves an auth record by user ID from the in-memory store

func (*InMemoryAuthRepository) UpdateAuth

func (r *InMemoryAuthRepository) UpdateAuth(ctx context.Context, auth *auth.Auth) error

UpdateAuth updates an existing auth record in the in-memory store

type InMemoryCustomerStore

type InMemoryCustomerStore struct {
	*InMemoryStore[*customer.Customer]
}

InMemoryCustomerStore implements customer.Repository

func NewInMemoryCustomerStore

func NewInMemoryCustomerStore() *InMemoryCustomerStore

NewInMemoryCustomerStore creates a new in-memory customer store

func (*InMemoryCustomerStore) Count

func (*InMemoryCustomerStore) Create

func (*InMemoryCustomerStore) Delete

func (s *InMemoryCustomerStore) Delete(ctx context.Context, id string) error

func (*InMemoryCustomerStore) Get

func (*InMemoryCustomerStore) GetByLookupKey

func (s *InMemoryCustomerStore) GetByLookupKey(ctx context.Context, lookupKey string) (*customer.Customer, error)

func (*InMemoryCustomerStore) List

func (*InMemoryCustomerStore) ListAll

func (*InMemoryCustomerStore) Update

type InMemoryEntitlementStore

type InMemoryEntitlementStore struct {
	*InMemoryStore[*entitlement.Entitlement]
}

InMemoryEntitlementStore implements entitlement.Repository

func NewInMemoryEntitlementStore

func NewInMemoryEntitlementStore() *InMemoryEntitlementStore

NewInMemoryEntitlementStore creates a new in-memory entitlement store

func (*InMemoryEntitlementStore) Clear

func (s *InMemoryEntitlementStore) Clear()

Clear clears the entitlement store

func (*InMemoryEntitlementStore) Count

func (*InMemoryEntitlementStore) Create

func (*InMemoryEntitlementStore) CreateBulk

func (s *InMemoryEntitlementStore) CreateBulk(ctx context.Context, entitlements []*entitlement.Entitlement) ([]*entitlement.Entitlement, error)

func (*InMemoryEntitlementStore) Delete

func (*InMemoryEntitlementStore) DeleteBulk

func (s *InMemoryEntitlementStore) DeleteBulk(ctx context.Context, ids []string) error

func (*InMemoryEntitlementStore) Get

func (*InMemoryEntitlementStore) List

func (*InMemoryEntitlementStore) Update

type InMemoryEnvironmentStore

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

func NewInMemoryEnvironmentStore

func NewInMemoryEnvironmentStore() *InMemoryEnvironmentStore

func (*InMemoryEnvironmentStore) Clear

func (s *InMemoryEnvironmentStore) Clear()

func (*InMemoryEnvironmentStore) Create

func (*InMemoryEnvironmentStore) Get

func (*InMemoryEnvironmentStore) List

func (*InMemoryEnvironmentStore) Update

type InMemoryEventStore

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

func NewInMemoryEventStore

func NewInMemoryEventStore() *InMemoryEventStore

func (*InMemoryEventStore) Clear

func (s *InMemoryEventStore) Clear()

func (*InMemoryEventStore) GetEvents

func (s *InMemoryEventStore) GetEvents(ctx context.Context, params *events.GetEventsParams) ([]*events.Event, error)

func (*InMemoryEventStore) GetUsage

func (*InMemoryEventStore) GetUsageWithFilters

func (s *InMemoryEventStore) GetUsageWithFilters(ctx context.Context, params *events.UsageWithFiltersParams) ([]*events.AggregationResult, error)

func (*InMemoryEventStore) HasEvent

func (s *InMemoryEventStore) HasEvent(id string) bool

func (*InMemoryEventStore) InsertEvent

func (s *InMemoryEventStore) InsertEvent(ctx context.Context, event *events.Event) error

type InMemoryFeatureStore

type InMemoryFeatureStore struct {
	*InMemoryStore[*feature.Feature]
}

InMemoryFeatureStore implements feature.Repository

func NewInMemoryFeatureStore

func NewInMemoryFeatureStore() *InMemoryFeatureStore

NewInMemoryFeatureStore creates a new in-memory feature store

func (*InMemoryFeatureStore) Clear

func (s *InMemoryFeatureStore) Clear()

Clear clears the feature store

func (*InMemoryFeatureStore) Count

func (s *InMemoryFeatureStore) Count(ctx context.Context, filter *types.FeatureFilter) (int, error)

func (*InMemoryFeatureStore) Create

func (*InMemoryFeatureStore) CreateBulk

func (s *InMemoryFeatureStore) CreateBulk(ctx context.Context, features []*feature.Feature) ([]*feature.Feature, error)

func (*InMemoryFeatureStore) Delete

func (s *InMemoryFeatureStore) Delete(ctx context.Context, id string) error

func (*InMemoryFeatureStore) DeleteBulk

func (s *InMemoryFeatureStore) DeleteBulk(ctx context.Context, ids []string) error

func (*InMemoryFeatureStore) Get

func (*InMemoryFeatureStore) List

func (*InMemoryFeatureStore) ListAll

ListAll returns all features without pagination

func (*InMemoryFeatureStore) Update

type InMemoryInvoiceStore

type InMemoryInvoiceStore struct {
	*InMemoryStore[*invoice.Invoice]
}

InMemoryInvoiceStore implements invoice.Repository

func NewInMemoryInvoiceStore

func NewInMemoryInvoiceStore() *InMemoryInvoiceStore

NewInMemoryInvoiceStore creates a new in-memory invoice store

func (*InMemoryInvoiceStore) AddLineItems

func (s *InMemoryInvoiceStore) AddLineItems(ctx context.Context, invoiceID string, items []*invoice.InvoiceLineItem) error

func (*InMemoryInvoiceStore) Count

func (s *InMemoryInvoiceStore) Count(ctx context.Context, filter *types.InvoiceFilter) (int, error)

func (*InMemoryInvoiceStore) Create

func (*InMemoryInvoiceStore) CreateWithLineItems

func (s *InMemoryInvoiceStore) CreateWithLineItems(ctx context.Context, inv *invoice.Invoice) error

func (*InMemoryInvoiceStore) Delete

func (s *InMemoryInvoiceStore) Delete(ctx context.Context, id string) error

func (*InMemoryInvoiceStore) ExistsForPeriod

func (s *InMemoryInvoiceStore) ExistsForPeriod(ctx context.Context, subscriptionID string, periodStart, periodEnd time.Time) (bool, error)

func (*InMemoryInvoiceStore) Get

func (*InMemoryInvoiceStore) GetByIdempotencyKey

func (s *InMemoryInvoiceStore) GetByIdempotencyKey(ctx context.Context, key string) (*invoice.Invoice, error)

func (*InMemoryInvoiceStore) GetNextBillingSequence

func (s *InMemoryInvoiceStore) GetNextBillingSequence(ctx context.Context, subscriptionID string) (int, error)

func (*InMemoryInvoiceStore) GetNextInvoiceNumber

func (s *InMemoryInvoiceStore) GetNextInvoiceNumber(ctx context.Context) (string, error)

func (*InMemoryInvoiceStore) List

func (*InMemoryInvoiceStore) RemoveLineItems

func (s *InMemoryInvoiceStore) RemoveLineItems(ctx context.Context, invoiceID string, itemIDs []string) error

func (*InMemoryInvoiceStore) Update

type InMemoryKafka

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

func NewInMemoryKafka

func NewInMemoryKafka() *InMemoryKafka

func (*InMemoryKafka) Close

func (b *InMemoryKafka) Close() error

func (*InMemoryKafka) HasMessage

func (b *InMemoryKafka) HasMessage(topic, id string) bool

func (*InMemoryKafka) Publish

func (b *InMemoryKafka) Publish(ctx context.Context, event *events.Event) error

func (*InMemoryKafka) Subscribe

func (b *InMemoryKafka) Subscribe() chan *message.Message

type InMemoryMeterStore

type InMemoryMeterStore struct {
	*InMemoryStore[*meter.Meter]
}

InMemoryMeterStore implements meter.Repository

func NewInMemoryMeterStore

func NewInMemoryMeterStore() *InMemoryMeterStore

NewInMemoryMeterStore creates a new in-memory meter store

func (*InMemoryMeterStore) Count

func (s *InMemoryMeterStore) Count(ctx context.Context, filter *types.MeterFilter) (int, error)

func (*InMemoryMeterStore) CreateMeter

func (s *InMemoryMeterStore) CreateMeter(ctx context.Context, m *meter.Meter) error

func (*InMemoryMeterStore) DisableMeter

func (s *InMemoryMeterStore) DisableMeter(ctx context.Context, id string) error

func (*InMemoryMeterStore) GetMeter

func (s *InMemoryMeterStore) GetMeter(ctx context.Context, id string) (*meter.Meter, error)

func (*InMemoryMeterStore) List

func (s *InMemoryMeterStore) List(ctx context.Context, filter *types.MeterFilter) ([]*meter.Meter, error)

func (*InMemoryMeterStore) ListAll

func (s *InMemoryMeterStore) ListAll(ctx context.Context, filter *types.MeterFilter) ([]*meter.Meter, error)

func (*InMemoryMeterStore) UpdateMeter

func (s *InMemoryMeterStore) UpdateMeter(ctx context.Context, id string, filters []meter.Filter) error

type InMemoryPlanStore

type InMemoryPlanStore struct {
	*InMemoryStore[*plan.Plan]
}

InMemoryPlanStore implements plan.Repository

func NewInMemoryPlanStore

func NewInMemoryPlanStore() *InMemoryPlanStore

NewInMemoryPlanStore creates a new in-memory plan store

func (*InMemoryPlanStore) Clear

func (s *InMemoryPlanStore) Clear()

Clear clears the plan store

func (*InMemoryPlanStore) Count

func (s *InMemoryPlanStore) Count(ctx context.Context, filter *types.PlanFilter) (int, error)

func (*InMemoryPlanStore) Create

func (s *InMemoryPlanStore) Create(ctx context.Context, p *plan.Plan) error

func (*InMemoryPlanStore) Delete

func (s *InMemoryPlanStore) Delete(ctx context.Context, id string) error

func (*InMemoryPlanStore) Get

func (s *InMemoryPlanStore) Get(ctx context.Context, id string) (*plan.Plan, error)

func (*InMemoryPlanStore) GetByLookupKey

func (s *InMemoryPlanStore) GetByLookupKey(ctx context.Context, lookupKey string) (*plan.Plan, error)

GetByLookupKey retrieves a plan by its lookup key

func (*InMemoryPlanStore) List

func (s *InMemoryPlanStore) List(ctx context.Context, filter *types.PlanFilter) ([]*plan.Plan, error)

func (*InMemoryPlanStore) ListAll

func (s *InMemoryPlanStore) ListAll(ctx context.Context, filter *types.PlanFilter) ([]*plan.Plan, error)

ListAll returns all plans without pagination

func (*InMemoryPlanStore) Update

func (s *InMemoryPlanStore) Update(ctx context.Context, p *plan.Plan) error

type InMemoryPriceStore

type InMemoryPriceStore struct {
	*InMemoryStore[*price.Price]
}

InMemoryPriceStore implements price.Repository

func NewInMemoryPriceStore

func NewInMemoryPriceStore() *InMemoryPriceStore

func (*InMemoryPriceStore) Clear

func (s *InMemoryPriceStore) Clear()

Clear clears the price store

func (*InMemoryPriceStore) Count

func (s *InMemoryPriceStore) Count(ctx context.Context, filter *types.PriceFilter) (int, error)

func (*InMemoryPriceStore) Create

func (s *InMemoryPriceStore) Create(ctx context.Context, p *price.Price) error

func (*InMemoryPriceStore) CreateBulk

func (s *InMemoryPriceStore) CreateBulk(ctx context.Context, prices []*price.Price) error

CreateBulk creates multiple prices in bulk

func (*InMemoryPriceStore) Delete

func (s *InMemoryPriceStore) Delete(ctx context.Context, id string) error

func (*InMemoryPriceStore) DeleteBulk

func (s *InMemoryPriceStore) DeleteBulk(ctx context.Context, ids []string) error

DeleteBulk deletes multiple prices in bulk

func (*InMemoryPriceStore) Get

func (*InMemoryPriceStore) List

func (s *InMemoryPriceStore) List(ctx context.Context, filter *types.PriceFilter) ([]*price.Price, error)

func (*InMemoryPriceStore) ListAll

func (s *InMemoryPriceStore) ListAll(ctx context.Context, filter *types.PriceFilter) ([]*price.Price, error)

ListAll returns all prices without pagination

func (*InMemoryPriceStore) Update

func (s *InMemoryPriceStore) Update(ctx context.Context, p *price.Price) error

type InMemoryPubSub

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

InMemoryPubSub is an in-memory implementation of pubsub.PubSub interface

func NewInMemoryPubSub

func NewInMemoryPubSub() *InMemoryPubSub

NewInMemoryPubSub creates a new instance of InMemoryPubSub

func (*InMemoryPubSub) ClearMessages

func (ps *InMemoryPubSub) ClearMessages()

ClearMessages clears all stored messages

func (*InMemoryPubSub) Close

func (ps *InMemoryPubSub) Close() error

Close implements pubsub.PubSub interface

func (*InMemoryPubSub) GetMessages

func (ps *InMemoryPubSub) GetMessages(topic string) []*message.Message

GetMessages returns all messages published to a topic

func (*InMemoryPubSub) Publish

func (ps *InMemoryPubSub) Publish(ctx context.Context, topic string, msg *message.Message) error

Publish implements pubsub.Publisher interface

func (*InMemoryPubSub) Subscribe

func (ps *InMemoryPubSub) Subscribe(ctx context.Context, topic string) (<-chan *message.Message, error)

Subscribe implements pubsub.Subscriber interface

type InMemoryPublisherService

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

InMemoryPublisherService provides an in-memory implementation of publisher.Service for testing

func (*InMemoryPublisherService) Clear

func (p *InMemoryPublisherService) Clear()

Clear removes all published events and messages

func (*InMemoryPublisherService) GetEvents

func (p *InMemoryPublisherService) GetEvents() []*events.Event

GetEvents returns all published events

func (*InMemoryPublisherService) HasEvent

func (p *InMemoryPublisherService) HasEvent(id string) bool

HasEvent checks if an event with the given ID exists in publisher's memory

func (*InMemoryPublisherService) HasMessage

func (p *InMemoryPublisherService) HasMessage(topic, id string) bool

HasMessage checks if a message with the given ID exists in the given topic

func (*InMemoryPublisherService) Publish

func (p *InMemoryPublisherService) Publish(ctx context.Context, event *events.Event) error

Publish implements publisher.Service interface

func (*InMemoryPublisherService) Subscribe

func (p *InMemoryPublisherService) Subscribe() chan *message.Message

Subscribe returns a channel for receiving messages

type InMemorySecretStore

type InMemorySecretStore struct {
	*InMemoryStore[*secret.Secret]
}

InMemorySecretStore implements secret.Repository

func NewInMemorySecretStore

func NewInMemorySecretStore() *InMemorySecretStore

NewInMemorySecretStore creates a new in-memory secret store

func (*InMemorySecretStore) Clear

func (s *InMemorySecretStore) Clear()

Clear clears the secret store

func (*InMemorySecretStore) Count

func (s *InMemorySecretStore) Count(ctx context.Context, filter *types.SecretFilter) (int, error)

func (*InMemorySecretStore) Create

func (s *InMemorySecretStore) Create(ctx context.Context, secret *secret.Secret) error

func (*InMemorySecretStore) Delete

func (s *InMemorySecretStore) Delete(ctx context.Context, id string) error

func (*InMemorySecretStore) Get

func (*InMemorySecretStore) GetAPIKeyByValue

func (s *InMemorySecretStore) GetAPIKeyByValue(ctx context.Context, value string) (*secret.Secret, error)

func (*InMemorySecretStore) List

func (*InMemorySecretStore) ListAll

func (s *InMemorySecretStore) ListAll(ctx context.Context, filter *types.SecretFilter) ([]*secret.Secret, error)

func (*InMemorySecretStore) UpdateLastUsed

func (s *InMemorySecretStore) UpdateLastUsed(ctx context.Context, id string) error

type InMemoryStore

type InMemoryStore[T any] struct {
	// contains filtered or unexported fields
}

InMemoryStore implements a generic in-memory store

func NewInMemoryStore

func NewInMemoryStore[T any]() *InMemoryStore[T]

NewInMemoryStore creates a new InMemoryStore

func (*InMemoryStore[T]) Clear

func (s *InMemoryStore[T]) Clear()

Clear removes all items from the store

func (*InMemoryStore[T]) Count

func (s *InMemoryStore[T]) Count(ctx context.Context, filter interface{}, filterFn FilterFunc[T]) (int, error)

Count returns the total number of items matching the filter

func (*InMemoryStore[T]) Create

func (s *InMemoryStore[T]) Create(ctx context.Context, id string, item T) error

Create adds a new item to the store

func (*InMemoryStore[T]) Delete

func (s *InMemoryStore[T]) Delete(ctx context.Context, id string) error

Delete removes an item from the store

func (*InMemoryStore[T]) Get

func (s *InMemoryStore[T]) Get(ctx context.Context, id string) (T, error)

Get retrieves an item by ID

func (*InMemoryStore[T]) List

func (s *InMemoryStore[T]) List(ctx context.Context, filter interface{}, filterFn FilterFunc[T], sortFn SortFunc[T]) ([]T, error)

List retrieves items based on filter

func (*InMemoryStore[T]) Update

func (s *InMemoryStore[T]) Update(ctx context.Context, id string, item T) error

Update updates an existing item

type InMemorySubscriptionStore

type InMemorySubscriptionStore struct {
	*InMemoryStore[*subscription.Subscription]
	// contains filtered or unexported fields
}

InMemorySubscriptionStore implements subscription.Repository

func NewInMemorySubscriptionStore

func NewInMemorySubscriptionStore() *InMemorySubscriptionStore

func (*InMemorySubscriptionStore) Count

func (*InMemorySubscriptionStore) Create

func (*InMemorySubscriptionStore) CreatePause

CreatePause creates a new subscription pause

func (*InMemorySubscriptionStore) CreateWithLineItems

CreateWithLineItems creates a subscription with its line items

func (*InMemorySubscriptionStore) Delete

func (*InMemorySubscriptionStore) Get

func (*InMemorySubscriptionStore) GetPause

GetPause gets a subscription pause by ID

func (*InMemorySubscriptionStore) GetWithLineItems

GetWithLineItems gets a subscription with its line items

func (*InMemorySubscriptionStore) GetWithPauses

GetWithPauses gets a subscription with its pauses

func (*InMemorySubscriptionStore) List

func (*InMemorySubscriptionStore) ListAll

ListAll returns all subscriptions without pagination

func (*InMemorySubscriptionStore) ListAllTenant

ListAllTenant returns all subscriptions across all tenants NOTE: This is a potentially expensive operation and to be used only for CRONs

func (*InMemorySubscriptionStore) ListPauses

func (s *InMemorySubscriptionStore) ListPauses(ctx context.Context, subscriptionID string) ([]*subscription.SubscriptionPause, error)

ListPauses lists all pauses for a subscription

func (*InMemorySubscriptionStore) Update

func (*InMemorySubscriptionStore) UpdatePause

UpdatePause updates a subscription pause

type InMemoryTaskStore

type InMemoryTaskStore struct {
	*InMemoryStore[*task.Task]
}

InMemoryTaskStore implements task.Repository

func NewInMemoryTaskStore

func NewInMemoryTaskStore() *InMemoryTaskStore

NewInMemoryTaskStore creates a new in-memory task store

func (*InMemoryTaskStore) Count

func (s *InMemoryTaskStore) Count(ctx context.Context, filter *types.TaskFilter) (int, error)

func (*InMemoryTaskStore) Create

func (s *InMemoryTaskStore) Create(ctx context.Context, t *task.Task) error

func (*InMemoryTaskStore) Delete

func (s *InMemoryTaskStore) Delete(ctx context.Context, id string) error

func (*InMemoryTaskStore) Get

func (s *InMemoryTaskStore) Get(ctx context.Context, id string) (*task.Task, error)

func (*InMemoryTaskStore) List

func (s *InMemoryTaskStore) List(ctx context.Context, filter *types.TaskFilter) ([]*task.Task, error)

func (*InMemoryTaskStore) Update

func (s *InMemoryTaskStore) Update(ctx context.Context, t *task.Task) error

type InMemoryTenantStore

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

func NewInMemoryTenantStore

func NewInMemoryTenantStore() *InMemoryTenantStore

func (*InMemoryTenantStore) Clear

func (s *InMemoryTenantStore) Clear()

func (*InMemoryTenantStore) Create

func (*InMemoryTenantStore) GetByID

func (s *InMemoryTenantStore) GetByID(ctx context.Context, id string) (*tenant.Tenant, error)

func (*InMemoryTenantStore) List

type InMemoryUserStore

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

InMemoryUserStore is an in-memory implementation of the User repository

func NewInMemoryUserStore

func NewInMemoryUserStore() *InMemoryUserStore

NewInMemoryUserStore creates a new instance of InMemoryUserStore

func (*InMemoryUserStore) Clear

func (s *InMemoryUserStore) Clear()

func (*InMemoryUserStore) Create

func (r *InMemoryUserStore) Create(ctx context.Context, user *user.User) error

Create creates a new user in the in-memory store

func (*InMemoryUserStore) GetByEmail

func (r *InMemoryUserStore) GetByEmail(ctx context.Context, email string) (*user.User, error)

GetByEmail retrieves a user by email from the in-memory store

func (*InMemoryUserStore) GetByID

func (r *InMemoryUserStore) GetByID(ctx context.Context, userID string) (*user.User, error)

GetByID retrieves a user by ID from the in-memory store

type InMemoryWalletStore

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

func NewInMemoryWalletStore

func NewInMemoryWalletStore() *InMemoryWalletStore

func (*InMemoryWalletStore) Clear

func (s *InMemoryWalletStore) Clear()

func (*InMemoryWalletStore) ConsumeCredits

func (s *InMemoryWalletStore) ConsumeCredits(ctx context.Context, credits []*wallet.Transaction, amount decimal.Decimal) error

ConsumeCredits processes debit operation across multiple credits

func (*InMemoryWalletStore) CountWalletTransactions

func (s *InMemoryWalletStore) CountWalletTransactions(ctx context.Context, f *types.WalletTransactionFilter) (int, error)

func (*InMemoryWalletStore) CreateTransaction

func (s *InMemoryWalletStore) CreateTransaction(ctx context.Context, tx *wallet.Transaction) error

CreateTransaction creates a new wallet transaction record

func (*InMemoryWalletStore) CreateWallet

func (s *InMemoryWalletStore) CreateWallet(ctx context.Context, w *wallet.Wallet) error

func (*InMemoryWalletStore) FindEligibleCredits

func (s *InMemoryWalletStore) FindEligibleCredits(ctx context.Context, walletID string, requiredAmount decimal.Decimal, pageSize int) ([]*wallet.Transaction, error)

FindEligibleCredits retrieves valid credits for debit operation with pagination

func (*InMemoryWalletStore) GetTransactionByID

func (s *InMemoryWalletStore) GetTransactionByID(ctx context.Context, id string) (*wallet.Transaction, error)

func (*InMemoryWalletStore) GetWalletByID

func (s *InMemoryWalletStore) GetWalletByID(ctx context.Context, id string) (*wallet.Wallet, error)

func (*InMemoryWalletStore) GetWalletsByCustomerID

func (s *InMemoryWalletStore) GetWalletsByCustomerID(ctx context.Context, customerID string) ([]*wallet.Wallet, error)

func (*InMemoryWalletStore) ListAllWalletTransactions

func (s *InMemoryWalletStore) ListAllWalletTransactions(ctx context.Context, f *types.WalletTransactionFilter) ([]*wallet.Transaction, error)

func (*InMemoryWalletStore) ListWalletTransactions

func (s *InMemoryWalletStore) ListWalletTransactions(ctx context.Context, f *types.WalletTransactionFilter) ([]*wallet.Transaction, error)

func (*InMemoryWalletStore) UpdateTransactionStatus

func (s *InMemoryWalletStore) UpdateTransactionStatus(ctx context.Context, id string, status types.TransactionStatus) error

func (*InMemoryWalletStore) UpdateWallet

func (s *InMemoryWalletStore) UpdateWallet(ctx context.Context, id string, w *wallet.Wallet) error

UpdateWallet updates a wallet in the in-memory store

func (*InMemoryWalletStore) UpdateWalletBalance

func (s *InMemoryWalletStore) UpdateWalletBalance(ctx context.Context, walletID string, finalBalance, newCreditBalance decimal.Decimal) error

UpdateWalletBalance updates the wallet's balance and credit balance

func (*InMemoryWalletStore) UpdateWalletStatus

func (s *InMemoryWalletStore) UpdateWalletStatus(ctx context.Context, id string, status types.WalletStatus) error

type MockHTTPClient

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

MockHTTPClient implements a mock HTTP client for testing

func NewMockHTTPClient

func NewMockHTTPClient() *MockHTTPClient

NewMockHTTPClient creates a new mock HTTP client

func (*MockHTTPClient) Clear

func (m *MockHTTPClient) Clear()

Clear removes all registered responses

func (*MockHTTPClient) RegisterCSVResponse

func (m *MockHTTPClient) RegisterCSVResponse(url string, headers []string, records [][]string)

RegisterCSVResponse is a helper to register a CSV response

func (*MockHTTPClient) RegisterResponse

func (m *MockHTTPClient) RegisterResponse(url string, resp MockResponse)

RegisterResponse registers a mock response for a given URL

func (*MockHTTPClient) Send

Send implements the httpclient.Client interface

type MockPostgresClient

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

MockPostgresClient is a mock implementation of postgres client for testing

func (*MockPostgresClient) Querier

func (c *MockPostgresClient) Querier(ctx context.Context) *ent.Client

Querier returns the ent client

func (*MockPostgresClient) TxFromContext

func (c *MockPostgresClient) TxFromContext(ctx context.Context) *ent.Tx

TxFromContext returns the transaction from context if it exists

func (*MockPostgresClient) WithTx

func (c *MockPostgresClient) WithTx(ctx context.Context, fn func(context.Context) error) error

WithTx executes the given function within a transaction

type MockResponse

type MockResponse struct {
	StatusCode int
	Body       []byte
	Headers    map[string]string
}

MockResponse represents a mock HTTP response

type SortFunc

type SortFunc[T any] func(i, j T) bool

SortFunc is a generic sort function type

type Stores

type Stores struct {
	SubscriptionRepo subscription.Repository
	EventRepo        events.Repository
	PlanRepo         plan.Repository
	PriceRepo        price.Repository
	MeterRepo        meter.Repository
	CustomerRepo     customer.Repository
	InvoiceRepo      invoice.Repository
	WalletRepo       wallet.Repository
	AuthRepo         auth.Repository
	UserRepo         user.Repository
	TenantRepo       tenant.Repository
	EnvironmentRepo  environment.Repository
	EntitlementRepo  entitlement.Repository
	FeatureRepo      feature.Repository
	TaskRepo         task.Repository
	SecretRepo       secret.Repository
}

Stores holds all the repository interfaces for testing

Jump to

Keyboard shortcuts

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