testutils

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package testutils provides utilities and helpers for integration testing.

This package contains helper functions, mock servers, and utilities that are commonly used across integration tests. It follows the same patterns as the main testutils package but focuses on integration testing scenarios.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertEventuallyTrue

func AssertEventuallyTrue(t *testing.T, condition func() bool, timeout time.Duration, message string)

AssertEventuallyTrue asserts that a condition becomes true within a timeout.

func SkipIfNoRealProxmox

func SkipIfNoRealProxmox(t *testing.T)

SkipIfNoRealProxmox skips the test if not running against real Proxmox.

func SkipIfRealProxmox

func SkipIfRealProxmox(t *testing.T)

SkipIfRealProxmox skips the test if running against real Proxmox.

func WaitForCondition

func WaitForCondition(t *testing.T, condition func() bool, timeout time.Duration, message string)

WaitForCondition waits for a condition to be true with timeout.

Types

type IntegrationTestConfig

type IntegrationTestConfig struct {
	TempDir        string
	ConfigFile     string
	CacheDir       string
	LogFile        string
	UseRealProxmox bool
	ProxmoxAddr    string
	ProxmoxUser    string
	ProxmoxPass    string
}

IntegrationTestConfig holds configuration for integration tests.

func NewIntegrationTestConfig

func NewIntegrationTestConfig(t *testing.T) *IntegrationTestConfig

NewIntegrationTestConfig creates a new integration test configuration.

func (*IntegrationTestConfig) CreateTestConfig

func (itc *IntegrationTestConfig) CreateTestConfig() *config.Config

CreateTestConfig creates a test configuration object.

func (*IntegrationTestConfig) CreateTestConfigFile

func (itc *IntegrationTestConfig) CreateTestConfigFile(t *testing.T, configContent string)

CreateTestConfigFile creates a configuration file for testing.

func (*IntegrationTestConfig) SetupIntegrationTest

func (itc *IntegrationTestConfig) SetupIntegrationTest(t *testing.T) (*config.Config, interfaces.Logger, interfaces.Cache, *api.Client)

SetupIntegrationTest sets up a complete integration test environment.

type MockProxmoxServer

type MockProxmoxServer struct {
	*httptest.Server
	// contains filtered or unexported fields
}

MockProxmoxServer creates a mock Proxmox API server for testing.

func NewMockProxmoxServer

func NewMockProxmoxServer() *MockProxmoxServer

NewMockProxmoxServer creates a new mock Proxmox server.

func (*MockProxmoxServer) Close

func (m *MockProxmoxServer) Close()

Close closes the mock server.

func (*MockProxmoxServer) GetURL

func (m *MockProxmoxServer) GetURL() string

GetURL returns the mock server URL.

func (*MockProxmoxServer) SetResponse

func (m *MockProxmoxServer) SetResponse(path string, response interface{})

SetResponse sets a mock response for a specific endpoint.

Jump to

Keyboard shortcuts

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