common

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2025 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupTestSuites

func CleanupTestSuites(suites ...*TestSuite)

CleanupTestSuites is a helper to clean up all test suites in a test

func CopyDir

func CopyDir(src, dst string) error

Helper to copy directories recursively

func CopyFile

func CopyFile(src, dst string) error

Helper to copy a single file

func FindRepoRoot

func FindRepoRoot() (string, error)

FindRepoRoot locates the repository root by looking for specific indicators Exported so it can be used by other packages

func SnapshotTest

func SnapshotTest(t *testing.T, languageName, toolName, testName, actualResult string)

SnapshotTest compares the actual result against an expected result file If the file doesn't exist or UPDATE_SNAPSHOTS=true env var is set, it will update the snapshot

Types

type LSPTestConfig

type LSPTestConfig struct {
	Name             string   // Name of the language server
	Command          string   // Command to run
	Args             []string // Arguments
	WorkspaceDir     string   // Template workspace directory
	InitializeTimeMs int      // Time to wait after initialization in ms
}

LSPTestConfig defines configuration for a language server test

type Logger

type Logger interface {
	Printf(format string, v ...any)
}

Logger is an interface for logging in tests

type TestSuite

type TestSuite struct {
	Config       LSPTestConfig
	Client       *lsp.Client
	WorkspaceDir string
	TempDir      string
	Context      context.Context
	Cancel       context.CancelFunc
	Watcher      *watcher.WorkspaceWatcher

	LanguageName string
	// contains filtered or unexported fields
}

TestSuite contains everything needed for running integration tests

func NewTestSuite

func NewTestSuite(t *testing.T, config LSPTestConfig) *TestSuite

NewTestSuite creates a new test suite for the given language server

func (*TestSuite) Cleanup

func (ts *TestSuite) Cleanup()

Cleanup stops the LSP and cleans up resources

func (*TestSuite) ReadFile

func (ts *TestSuite) ReadFile(relPath string) (string, error)

ReadFile reads a file from the workspace

func (*TestSuite) Setup

func (ts *TestSuite) Setup() error

Setup initializes the test suite, copies the workspace, and starts the LSP

func (*TestSuite) WriteFile

func (ts *TestSuite) WriteFile(relPath, content string) error

WriteFile writes content to a file in the workspace

Jump to

Keyboard shortcuts

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