Skip to main content

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 created Manager instance.

TestAvailableIntegrationsRepo

  • Purpose: Mock implementation of availableIntegrationsRepo for testing.
  • Parameters: None
  • Returns: None

(*TestAvailableIntegrationsRepo) list

  • Purpose: Implements the list method for the TestAvailableIntegrationsRepo. Returns a predefined list of IntegrationDetails for testing.
  • Parameters:
    • ctx (context.Context): The context for the operation.
  • Returns:
    • []IntegrationDetails: A slice containing two predefined IntegrationDetails structs.
    • *model.ApiError: Always returns nil.

(*TestAvailableIntegrationsRepo) get

  • Purpose: Implements the get method for the TestAvailableIntegrationsRepo. Returns a map of IntegrationDetails based on the provided IDs, using the predefined list from the list 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 corresponding IntegrationDetails.
    • *model.ApiError: Returns nil if successful, otherwise returns the error from t.list(ctx).

Code Examples

None.

Include in Getting Started: NO