test_utils.go
test_utils.go - Overview
This file provides utility functions and mock implementations for testing the integrations manager. It includes a function to create a test integrations manager and a mock repository for available integrations.
Detailed Documentation
NewTestIntegrationsManager
- Purpose: Creates a new
Manager
instance for testing purposes, using an in-memory SQLite database and a mock available integrations repository. - Parameters:
t
(*testing.T): The testing object used for test execution and reporting.
- Returns:
*Manager
: A pointer to the newly createdManager
instance.
TestAvailableIntegrationsRepo
- Purpose: Mock implementation of
availableIntegrationsRepo
for testing. - Parameters: None
- Returns: None
(*TestAvailableIntegrationsRepo) list
- Purpose: Implements the
list
method for theTestAvailableIntegrationsRepo
. Returns a predefined list ofIntegrationDetails
for testing. - Parameters:
ctx
(context.Context): The context for the operation.
- Returns:
[]IntegrationDetails
: A slice containing two predefinedIntegrationDetails
structs.*model.ApiError
: Always returnsnil
.
(*TestAvailableIntegrationsRepo) get
- Purpose: Implements the
get
method for theTestAvailableIntegrationsRepo
. Returns a map ofIntegrationDetails
based on the provided IDs, using the predefined list from thelist
method. - Parameters:
ctx
(context.Context): The context for the operation.ids
([]string): A slice of integration IDs to retrieve.
- Returns:
map[string]IntegrationDetails
: A map of integration IDs to their correspondingIntegrationDetails
.*model.ApiError
: Returnsnil
if successful, otherwise returns the error fromt.list(ctx)
.
Code Examples
None.
Include in Getting Started: NO