harness

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertCommandFailure

func AssertCommandFailure(t testing.TB, h *E2EHarness, args ...string) (stdout, stderr string, exitCode int)

AssertCommandFailure runs a command and asserts it fails

func AssertCommandSuccess

func AssertCommandSuccess(t testing.TB, h *E2EHarness, args ...string) (stdout, stderr string)

AssertCommandSuccess runs a command and asserts it succeeds

func AssertContains

func AssertContains(t testing.TB, output, expected string)

AssertContains checks that output contains expected string

func AssertEmpty

func AssertEmpty(t testing.TB, output string, label string)

AssertEmpty checks that output is empty

func AssertEqual

func AssertEqual(t testing.TB, expected, actual any, label string)

AssertEqual checks that two values are equal

func AssertError

func AssertError(t testing.TB, err error, context string)

AssertError checks that an error occurred

func AssertErrorContains

func AssertErrorContains(t testing.TB, err error, expectedMsg string, context string)

AssertErrorContains checks that an error occurred and contains expected message

func AssertExitCode

func AssertExitCode(t testing.TB, expected, actual int, stdout, stderr string)

AssertExitCode checks that a command exited with the expected code

func AssertFalse

func AssertFalse(t testing.TB, condition bool, message string)

AssertFalse checks that a condition is false

func AssertFileExists

func AssertFileExists(t testing.TB, h *E2EHarness, filename string)

AssertFileExists checks that a file exists in the harness memory directory

func AssertListLength

func AssertListLength(t testing.TB, list any, expectedLen int, label string)

AssertListLength checks that a list has the expected length

func AssertMapContains

func AssertMapContains(t testing.TB, m map[string]any, key string, expectedValue any)

AssertMapContains checks that a map contains a key with expected value

func AssertMapHasKey

func AssertMapHasKey(t testing.TB, m map[string]any, key string)

AssertMapHasKey checks that a map contains a key

func AssertNoError

func AssertNoError(t testing.TB, err error, context string)

AssertNoError checks that an error is nil

func AssertNotContains

func AssertNotContains(t testing.TB, output, notExpected string)

AssertNotContains checks that output does not contain a string

func AssertNotEmpty

func AssertNotEmpty(t testing.TB, output string, label string)

AssertNotEmpty checks that output is not empty

func AssertTrue

func AssertTrue(t testing.TB, condition bool, message string)

AssertTrue checks that a condition is true

func DumpDaemonLogs

func DumpDaemonLogs(t testing.TB, h *E2EHarness)

DumpDaemonLogs reads and logs the daemon log file for debugging

func FormatError

func FormatError(context string, err error) string

FormatError formats an error with context for better test output

func LogOutput

func LogOutput(t testing.TB, stdout, stderr string)

LogOutput logs command output for debugging

func RetryUntilSuccess

func RetryUntilSuccess(t testing.TB, fn func() error, timeout, interval string) error

RetryUntilSuccess retries a function until it succeeds or times out

Types

type Cleanup

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

Cleanup handles cleanup operations for E2E tests

func MustCleanup

func MustCleanup(t testing.TB, h *E2EHarness) *Cleanup

MustCleanup creates a cleanup manager and registers it with t.Cleanup()

func NewCleanup

func NewCleanup(t testing.TB, h *E2EHarness) *Cleanup

NewCleanup creates a new cleanup manager

func (*Cleanup) CleanupAll

func (c *Cleanup) CleanupAll()

CleanupAll performs all cleanup operations

func (*Cleanup) ClearGraph

func (c *Cleanup) ClearGraph() error

ClearGraph clears all data from the test graph

func (*Cleanup) KillDaemonProcess

func (c *Cleanup) KillDaemonProcess() error

KillDaemonProcess forcefully kills the daemon process (last resort)

func (*Cleanup) Register

func (c *Cleanup) Register(fn func() error)

Register adds a cleanup function to be called on teardown

func (*Cleanup) RemoveTestFiles

func (c *Cleanup) RemoveTestFiles() error

RemoveTestFiles removes all test files from memory directory

func (*Cleanup) Run

func (c *Cleanup) Run()

Run executes all registered cleanup functions

func (*Cleanup) StopDaemon

func (c *Cleanup) StopDaemon() error

StopDaemon ensures the daemon is stopped

func (*Cleanup) WaitForDaemonStop

func (c *Cleanup) WaitForDaemonStop(timeout time.Duration) error

WaitForDaemonStop waits for the daemon to stop gracefully

type E2EHarness

type E2EHarness struct {
	// Test environment paths
	AppDir     string
	MemoryRoot string
	ConfigPath string
	PIDPath    string
	LogPath    string
	BinaryPath string
	GraphName  string // Unique graph name for test isolation

	// Test clients
	MCPClient   *MCPClient
	GraphClient *GraphClient
	HTTPClient  *HTTPClient
	// contains filtered or unexported fields
}

E2EHarness provides a complete test environment for end-to-end tests

func New

func New(t testing.TB) *E2EHarness

New creates a new E2E test harness

func (*E2EHarness) AddMemoryFile

func (h *E2EHarness) AddMemoryFile(name, content string) error

AddMemoryFile creates a file in the memory directory

func (*E2EHarness) EnableHTTPServer

func (h *E2EHarness) EnableHTTPServer(port int) error

EnableHTTPServer enables the HTTP server on the specified port

func (*E2EHarness) RunCommand

func (h *E2EHarness) RunCommand(args ...string) (stdout, stderr string, exitCode int)

RunCommand runs the agentic-memorizer binary with the given arguments

func (*E2EHarness) Setup

func (h *E2EHarness) Setup() error

Setup initializes the test environment

func (*E2EHarness) StartDaemon

func (h *E2EHarness) StartDaemon() error

StartDaemon starts the daemon process

func (*E2EHarness) StopDaemon

func (h *E2EHarness) StopDaemon() error

StopDaemon stops the daemon process

func (*E2EHarness) Teardown

func (h *E2EHarness) Teardown() error

Teardown cleans up the test environment

func (*E2EHarness) WaitForHealthy

func (h *E2EHarness) WaitForHealthy(timeout time.Duration) error

WaitForHealthy polls the health endpoint until daemon is ready

type GraphClient

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

GraphClient provides a test client for FalkorDB operations

func NewGraphClient

func NewGraphClient(host, port, graphName string) *GraphClient

NewGraphClient creates a new FalkorDB test client

func (*GraphClient) Clear

func (c *GraphClient) Clear(ctx context.Context) error

Clear clears all data from the test graph

func (*GraphClient) Close

func (c *GraphClient) Close() error

Close closes the FalkorDB connection

func (*GraphClient) Connect

func (c *GraphClient) Connect() error

Connect establishes connection to FalkorDB

func (*GraphClient) CountNodes

func (c *GraphClient) CountNodes(ctx context.Context, label string) (int, error)

CountNodes counts nodes of a specific label

func (*GraphClient) DropGraph

func (c *GraphClient) DropGraph(ctx context.Context) error

DropGraph completely drops the test graph (for test cleanup) Note: With unique graph names per test, simple Clear() is sufficient for cleanup

func (*GraphClient) FileExists

func (c *GraphClient) FileExists(ctx context.Context, path string) (bool, error)

FileExists checks if a file node exists in the graph

func (*GraphClient) GetFileTags

func (c *GraphClient) GetFileTags(ctx context.Context, path string) ([]string, error)

GetFileTags retrieves tags for a specific file

func (*GraphClient) GetRelatedFiles

func (c *GraphClient) GetRelatedFiles(ctx context.Context, path string, limit int) ([]string, error)

GetRelatedFiles finds files related to a given file via shared tags/topics

func (*GraphClient) Query

func (c *GraphClient) Query(ctx context.Context, query string) (falkordb.QueryResult, error)

Query executes a Cypher query

type HTTPClient

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

HTTPClient provides a test client for the daemon's HTTP API

func NewHTTPClient

func NewHTTPClient(host string, port int) *HTTPClient

NewHTTPClient creates a new HTTP test client

func (*HTTPClient) GetFileMetadata

func (c *HTTPClient) GetFileMetadata(path string) (any, error)

GetFileMetadata retrieves metadata for a specific file

func (*HTTPClient) GetIndex

func (c *HTTPClient) GetIndex() (any, error)

GetIndex retrieves the full index from the graph

func (*HTTPClient) GetRelatedFiles

func (c *HTTPClient) GetRelatedFiles(path string, limit int) (any, error)

GetRelatedFiles finds files related to a given file

func (*HTTPClient) Health

func (c *HTTPClient) Health() (map[string]any, error)

Health checks the daemon health endpoint

func (*HTTPClient) ListRecentFiles

func (c *HTTPClient) ListRecentFiles(days, limit int) (any, error)

ListRecentFiles lists recently modified files

func (*HTTPClient) SearchEntities

func (c *HTTPClient) SearchEntities(entity string, maxResults int) (any, error)

SearchEntities searches for files mentioning a specific entity

func (*HTTPClient) SearchFiles

func (c *HTTPClient) SearchFiles(query string, maxResults int) (any, error)

SearchFiles performs a semantic search

func (*HTTPClient) SetPort

func (c *HTTPClient) SetPort(port int)

SetPort updates the HTTP client's port

func (*HTTPClient) TriggerRebuild

func (c *HTTPClient) TriggerRebuild(force bool) error

TriggerRebuild triggers a full index rebuild

func (*HTTPClient) WaitForHealthy

func (c *HTTPClient) WaitForHealthy(timeout time.Duration) error

WaitForHealthy polls the health endpoint until it responds or times out

type MCPClient

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

MCPClient simulates an MCP client for testing the MCP server

func NewMCPClient

func NewMCPClient(binaryPath, appDir string) (*MCPClient, error)

NewMCPClient creates a new MCP client that communicates with the server via stdio

func (*MCPClient) CallTool

func (c *MCPClient) CallTool(name string, args any) (any, error)

CallTool calls a tool with the given arguments

func (*MCPClient) Close

func (c *MCPClient) Close() error

Close closes the MCP client connection

func (*MCPClient) Initialize

func (c *MCPClient) Initialize() (*protocol.InitializeResponse, error)

Initialize sends the initialize request

func (*MCPClient) ListResources

func (c *MCPClient) ListResources() ([]protocol.Resource, error)

ListResources requests the list of available resources

func (*MCPClient) ListTools

func (c *MCPClient) ListTools() ([]protocol.Tool, error)

ListTools requests the list of available tools

func (*MCPClient) ReadResource

func (c *MCPClient) ReadResource(uri string) (string, error)

ReadResource reads a specific resource by URI

func (*MCPClient) Shutdown

func (c *MCPClient) Shutdown() error

Shutdown sends the shutdown request

Jump to

Keyboard shortcuts

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