strategies

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package strategies provides the strategy pattern implementation for test file parsing. Each test framework (Jest, Vitest, Playwright, Go testing) has its own strategy.

Index

Constants

View Source
const DefaultPriority = 100

DefaultPriority is the default priority for strategies. Higher priority strategies are checked first.

Variables

This section is empty.

Functions

func Register

func Register(s Strategy)

Register adds a strategy to the default registry.

Types

type Registry

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

Registry manages registered strategies.

func DefaultRegistry

func DefaultRegistry() *Registry

DefaultRegistry returns the global default registry.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new empty strategy registry.

func (*Registry) Clear

func (r *Registry) Clear()

Clear removes all registered strategies.

func (*Registry) FindByName added in v1.1.0

func (r *Registry) FindByName(name string) Strategy

FindByName returns the strategy with the given name.

func (*Registry) FindStrategy

func (r *Registry) FindStrategy(filename string, content []byte) Strategy

FindStrategy returns the first strategy that can handle the given file.

func (*Registry) GetStrategies

func (r *Registry) GetStrategies() []Strategy

GetStrategies returns a copy of all registered strategies.

func (*Registry) Register

func (r *Registry) Register(s Strategy)

Register adds a strategy to the registry.

type Strategy

type Strategy interface {
	// Name returns the strategy identifier (e.g., "jest", "vitest").
	Name() string
	// Priority returns the strategy priority (higher = checked first).
	Priority() int
	// Languages returns the languages this strategy supports.
	Languages() []domain.Language
	// CanHandle returns true if this strategy can parse the given file.
	CanHandle(filename string, content []byte) bool
	// Parse parses the source code and extracts test definitions.
	Parse(ctx context.Context, source []byte, filename string) (*domain.TestFile, error)
}

Strategy defines the interface for test framework-specific parsers.

func FindStrategy

func FindStrategy(filename string, content []byte) Strategy

FindStrategy returns the first matching strategy for the given file.

func FindStrategyByName added in v1.1.0

func FindStrategyByName(name string) Strategy

FindStrategyByName returns the strategy with the given name from the default registry.

func GetStrategies

func GetStrategies() []Strategy

GetStrategies returns all registered strategies from the default registry.

Directories

Path Synopsis
shared

Jump to

Keyboard shortcuts

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