integration

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 10 Imported by: 0

README

Integration Tests for Hex Phase 2

This directory contains end-to-end integration tests for the Hex CLI Phase 2 implementation.

Test Files

  1. helpers.go - Common test utilities and helper functions
  2. storage_test.go - Database persistence and conversation/message CRUD
  3. tools_test.go - Tool registry, executor, and individual tool tests
  4. api_test.go - Anthropic API client and streaming tests
  5. ui_test.go - UI model state and lifecycle tests (simplified)
  6. scenarios_test.go - End-to-end realistic user workflows

Running Tests

# Run all integration tests
go test ./test/integration/...

# Run in short mode (skips slow/API tests)
go test -short ./test/integration/...

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

# Run specific test
go test -run TestStorageIntegration ./test/integration/...

Test Requirements

Storage Tests
  • SQLite database created and initialized
  • Conversations and messages persisted
  • Foreign key constraints work
  • Timestamps update correctly
Tools Tests
  • All three tools (Read, Write, Bash) registered
  • Tools execute successfully
  • Approval/denial flow works
  • Concurrent execution is safe
API Tests (Skipped in Short Mode)
  • Require ANTHROPIC_API_KEY environment variable
  • Test streaming responses
  • Test token counting
  • Test error handling
UI Tests
  • Model initialization
  • State transitions
  • Message handling
  • Basic lifecycle
Scenario Tests
  • Complete workflows combining all components
  • Error recovery
  • Resume conversation
  • Multi-tool sequences

Notes

  • Tests use temporary databases (t.TempDir())
  • All tests clean up after themselves
  • API tests are skipped in -short mode
  • Some tests check for specific error messages (may be brittle)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertFileContains

func AssertFileContains(t *testing.T, path, expectedContent string)

AssertFileContains checks that a file contains expected content

func AssertFileExists

func AssertFileExists(t *testing.T, path string)

AssertFileExists checks that a file exists and has expected content

func CreateTestConversation

func CreateTestConversation(t *testing.T, db *sql.DB, model string) string

CreateTestConversation creates a conversation with test data

func CreateTestDir

func CreateTestDir(t *testing.T) string

CreateTestDir creates a temporary test directory

func CreateTestFile

func CreateTestFile(t *testing.T, content string) string

CreateTestFile creates a temporary test file with content

func CreateTestMessage

func CreateTestMessage(t *testing.T, db *sql.DB, conversationID, role, content string) string

CreateTestMessage creates a message in the database

func MockAPIClient

func MockAPIClient(t *testing.T, _ []core.MessageResponse) *core.Client

MockAPIClient returns a mock API client for testing This is a placeholder - actual implementation depends on whether you have mocking infrastructure

func SetupTestDB

func SetupTestDB(t *testing.T) *sql.DB

SetupTestDB creates a temporary test database

func WaitForCondition

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

WaitForCondition polls a condition function until it returns true or timeout

Types

This section is empty.

Jump to

Keyboard shortcuts

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