Documentation
¶
Overview ¶
Package adapters provides language-specific behavior for test generation.
Each language has a dedicated adapter implementing the LanguageAdapter interface, handling parsing, framework selection, test generation, and validation.
Index ¶
- type BaseAdapter
- type GoAdapter
- func (a *GoAdapter) CanHandle(filePath string) bool
- func (a *GoAdapter) ExtractDefinitions(ast *models.AST) ([]*models.Definition, error)
- func (a *GoAdapter) FormatTestCode(code string) (string, error)
- func (a *GoAdapter) GenerateTestPath(sourcePath string, outputDir string) string
- func (a *GoAdapter) GetPromptTemplate(testType string) string
- func (a *GoAdapter) ParseFile(content string) (*models.AST, error)
- func (a *GoAdapter) RunTests(testDir string) (*models.TestResults, error)
- func (a *GoAdapter) SelectFramework(projectPath string) string
- func (a *GoAdapter) ValidateTests(testCode string, testPath string) error
- type JavaAdapter
- func (a *JavaAdapter) CanHandle(filePath string) bool
- func (a *JavaAdapter) ExtractDefinitions(ast *models.AST) ([]*models.Definition, error)
- func (a *JavaAdapter) FormatTestCode(code string) (string, error)
- func (a *JavaAdapter) GenerateTestPath(sourcePath string, outputDir string) string
- func (a *JavaAdapter) GetPromptTemplate(testType string) string
- func (a *JavaAdapter) ParseFile(content string) (*models.AST, error)
- func (a *JavaAdapter) RunTests(testDir string) (*models.TestResults, error)
- func (a *JavaAdapter) SelectFramework(projectPath string) string
- func (a *JavaAdapter) ValidateTests(testCode string, testPath string) error
- type JavaScriptAdapter
- func (a *JavaScriptAdapter) CanHandle(filePath string) bool
- func (a *JavaScriptAdapter) ExtractDefinitions(ast *models.AST) ([]*models.Definition, error)
- func (a *JavaScriptAdapter) FormatTestCode(code string) (string, error)
- func (a *JavaScriptAdapter) GenerateTestPath(sourcePath string, outputDir string) string
- func (a *JavaScriptAdapter) GetPromptTemplate(testType string) string
- func (a *JavaScriptAdapter) ParseFile(content string) (*models.AST, error)
- func (a *JavaScriptAdapter) RunTests(testDir string) (*models.TestResults, error)
- func (a *JavaScriptAdapter) SelectFramework(projectPath string) string
- func (a *JavaScriptAdapter) ValidateTests(testCode string, testPath string) error
- type LanguageAdapter
- type PythonAdapter
- func (a *PythonAdapter) CanHandle(filePath string) bool
- func (a *PythonAdapter) ExtractDefinitions(ast *models.AST) ([]*models.Definition, error)
- func (a *PythonAdapter) FormatTestCode(code string) (string, error)
- func (a *PythonAdapter) GenerateTestPath(sourcePath string, outputDir string) string
- func (a *PythonAdapter) GetPromptTemplate(testType string) string
- func (a *PythonAdapter) ParseFile(content string) (*models.AST, error)
- func (a *PythonAdapter) RunTests(testDir string) (*models.TestResults, error)
- func (a *PythonAdapter) SelectFramework(projectPath string) string
- func (a *PythonAdapter) ValidateTests(testCode string, testPath string) error
- type Registry
- type RustAdapter
- func (a *RustAdapter) CanHandle(filePath string) bool
- func (a *RustAdapter) ExtractDefinitions(ast *models.AST) ([]*models.Definition, error)
- func (a *RustAdapter) FormatTestCode(code string) (string, error)
- func (a *RustAdapter) GenerateTestPath(sourcePath string, outputDir string) string
- func (a *RustAdapter) GetPromptTemplate(testType string) string
- func (a *RustAdapter) ParseFile(content string) (*models.AST, error)
- func (a *RustAdapter) RunTests(testDir string) (*models.TestResults, error)
- func (a *RustAdapter) SelectFramework(projectPath string) string
- func (a *RustAdapter) ValidateTests(testCode string, testPath string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseAdapter ¶
type BaseAdapter struct {
// contains filtered or unexported fields
}
BaseAdapter provides common functionality for all adapters
func (*BaseAdapter) GetDefaultFramework ¶
func (b *BaseAdapter) GetDefaultFramework() string
GetDefaultFramework returns the default framework
func (*BaseAdapter) GetLanguage ¶
func (b *BaseAdapter) GetLanguage() string
GetLanguage returns the language
func (*BaseAdapter) GetSupportedFrameworks ¶
func (b *BaseAdapter) GetSupportedFrameworks() []string
GetSupportedFrameworks returns supported frameworks
type GoAdapter ¶
type GoAdapter struct {
BaseAdapter
}
GoAdapter handles Go source files
func (*GoAdapter) ExtractDefinitions ¶
ExtractDefinitions returns definitions from parsed AST
func (*GoAdapter) FormatTestCode ¶
FormatTestCode formats Go test code using gofmt
func (*GoAdapter) GenerateTestPath ¶
GenerateTestPath returns the expected path for a test file
func (*GoAdapter) GetPromptTemplate ¶
GetPromptTemplate returns the prompt template for Go tests
func (*GoAdapter) RunTests ¶
func (a *GoAdapter) RunTests(testDir string) (*models.TestResults, error)
RunTests executes Go tests and returns results
func (*GoAdapter) SelectFramework ¶
SelectFramework determines the test framework to use
type JavaAdapter ¶
type JavaAdapter struct {
BaseAdapter
}
JavaAdapter handles Java source files
func NewJavaAdapter ¶
func NewJavaAdapter() *JavaAdapter
NewJavaAdapter creates a new Java language adapter
func (*JavaAdapter) CanHandle ¶
func (a *JavaAdapter) CanHandle(filePath string) bool
CanHandle returns true if this adapter can handle the file
func (*JavaAdapter) ExtractDefinitions ¶
func (a *JavaAdapter) ExtractDefinitions(ast *models.AST) ([]*models.Definition, error)
ExtractDefinitions returns definitions from parsed AST
func (*JavaAdapter) FormatTestCode ¶
func (a *JavaAdapter) FormatTestCode(code string) (string, error)
FormatTestCode formats Java test code
func (*JavaAdapter) GenerateTestPath ¶
func (a *JavaAdapter) GenerateTestPath(sourcePath string, outputDir string) string
GenerateTestPath returns the expected path for a test file
func (*JavaAdapter) GetPromptTemplate ¶
func (a *JavaAdapter) GetPromptTemplate(testType string) string
GetPromptTemplate returns the prompt template for Java tests
func (*JavaAdapter) ParseFile ¶
func (a *JavaAdapter) ParseFile(content string) (*models.AST, error)
ParseFile parses Java source code
func (*JavaAdapter) RunTests ¶
func (a *JavaAdapter) RunTests(testDir string) (*models.TestResults, error)
RunTests executes Java tests and returns results
func (*JavaAdapter) SelectFramework ¶
func (a *JavaAdapter) SelectFramework(projectPath string) string
SelectFramework determines the test framework to use
func (*JavaAdapter) ValidateTests ¶
func (a *JavaAdapter) ValidateTests(testCode string, testPath string) error
ValidateTests checks if generated tests have valid syntax
type JavaScriptAdapter ¶
type JavaScriptAdapter struct {
BaseAdapter
}
JavaScriptAdapter handles JavaScript and TypeScript source files
func NewJavaScriptAdapter ¶
func NewJavaScriptAdapter() *JavaScriptAdapter
NewJavaScriptAdapter creates a new JavaScript/TypeScript language adapter
func (*JavaScriptAdapter) CanHandle ¶
func (a *JavaScriptAdapter) CanHandle(filePath string) bool
CanHandle returns true if this adapter can handle the file
func (*JavaScriptAdapter) ExtractDefinitions ¶
func (a *JavaScriptAdapter) ExtractDefinitions(ast *models.AST) ([]*models.Definition, error)
ExtractDefinitions returns definitions from parsed AST
func (*JavaScriptAdapter) FormatTestCode ¶
func (a *JavaScriptAdapter) FormatTestCode(code string) (string, error)
FormatTestCode formats JavaScript/TypeScript test code
func (*JavaScriptAdapter) GenerateTestPath ¶
func (a *JavaScriptAdapter) GenerateTestPath(sourcePath string, outputDir string) string
GenerateTestPath returns the expected path for a test file
func (*JavaScriptAdapter) GetPromptTemplate ¶
func (a *JavaScriptAdapter) GetPromptTemplate(testType string) string
GetPromptTemplate returns the prompt template for JavaScript tests
func (*JavaScriptAdapter) ParseFile ¶
func (a *JavaScriptAdapter) ParseFile(content string) (*models.AST, error)
ParseFile parses JavaScript/TypeScript source code
func (*JavaScriptAdapter) RunTests ¶
func (a *JavaScriptAdapter) RunTests(testDir string) (*models.TestResults, error)
RunTests executes JavaScript tests and returns results
func (*JavaScriptAdapter) SelectFramework ¶
func (a *JavaScriptAdapter) SelectFramework(projectPath string) string
SelectFramework determines the test framework to use
func (*JavaScriptAdapter) ValidateTests ¶
func (a *JavaScriptAdapter) ValidateTests(testCode string, testPath string) error
ValidateTests checks if generated tests have valid syntax
type LanguageAdapter ¶
type LanguageAdapter interface {
// CanHandle returns true if this adapter handles the given file
CanHandle(filePath string) bool
// GetLanguage returns the language this adapter handles
GetLanguage() string
// GetDefaultFramework returns the default test framework for this language
GetDefaultFramework() string
// GetSupportedFrameworks returns all supported test frameworks
GetSupportedFrameworks() []string
// ParseFile parses source code and returns an AST
ParseFile(content string) (*models.AST, error)
// ExtractDefinitions extracts functions and methods from parsed AST
ExtractDefinitions(ast *models.AST) ([]*models.Definition, error)
// SelectFramework determines the test framework to use
SelectFramework(projectPath string) string
// GenerateTestPath returns the expected path for a test file
GenerateTestPath(sourcePath string, outputDir string) string
// FormatTestCode formats the generated test code
FormatTestCode(code string) (string, error)
// GetPromptTemplate returns the prompt template for the given test type
GetPromptTemplate(testType string) string
// ValidateTests checks if generated tests compile/parse correctly
ValidateTests(testCode string, testPath string) error
// RunTests executes tests and returns results
RunTests(testDir string) (*models.TestResults, error)
}
LanguageAdapter defines the interface for language-specific test generation
type PythonAdapter ¶
type PythonAdapter struct {
BaseAdapter
}
PythonAdapter handles Python source files
func NewPythonAdapter ¶
func NewPythonAdapter() *PythonAdapter
NewPythonAdapter creates a new Python language adapter
func (*PythonAdapter) CanHandle ¶
func (a *PythonAdapter) CanHandle(filePath string) bool
CanHandle returns true if this adapter can handle the file
func (*PythonAdapter) ExtractDefinitions ¶
func (a *PythonAdapter) ExtractDefinitions(ast *models.AST) ([]*models.Definition, error)
ExtractDefinitions returns definitions from parsed AST
func (*PythonAdapter) FormatTestCode ¶
func (a *PythonAdapter) FormatTestCode(code string) (string, error)
FormatTestCode formats Python test code
func (*PythonAdapter) GenerateTestPath ¶
func (a *PythonAdapter) GenerateTestPath(sourcePath string, outputDir string) string
GenerateTestPath returns the expected path for a test file
func (*PythonAdapter) GetPromptTemplate ¶
func (a *PythonAdapter) GetPromptTemplate(testType string) string
GetPromptTemplate returns the prompt template for Python tests
func (*PythonAdapter) ParseFile ¶
func (a *PythonAdapter) ParseFile(content string) (*models.AST, error)
ParseFile parses Python source code and extracts structure
func (*PythonAdapter) RunTests ¶
func (a *PythonAdapter) RunTests(testDir string) (*models.TestResults, error)
RunTests executes Python tests and returns results
func (*PythonAdapter) SelectFramework ¶
func (a *PythonAdapter) SelectFramework(projectPath string) string
SelectFramework determines the test framework to use
func (*PythonAdapter) ValidateTests ¶
func (a *PythonAdapter) ValidateTests(testCode string, testPath string) error
ValidateTests checks if generated tests are valid Python
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages language adapters
func DefaultRegistry ¶
func DefaultRegistry() *Registry
DefaultRegistry returns the singleton registry with all default adapters
func (*Registry) GetAdapter ¶
func (r *Registry) GetAdapter(language string) LanguageAdapter
GetAdapter returns the adapter for a language
func (*Registry) GetAdapterForFile ¶
func (r *Registry) GetAdapterForFile(filePath string) LanguageAdapter
GetAdapterForFile returns the adapter for a file based on its extension
func (*Registry) HasAdapter ¶
HasAdapter returns true if an adapter exists for the language
func (*Registry) ListLanguages ¶
ListLanguages returns all registered languages
func (*Registry) Register ¶
func (r *Registry) Register(adapter LanguageAdapter)
Register adds an adapter to the registry
type RustAdapter ¶
type RustAdapter struct {
BaseAdapter
}
RustAdapter handles Rust source files
func NewRustAdapter ¶
func NewRustAdapter() *RustAdapter
NewRustAdapter creates a new Rust language adapter
func (*RustAdapter) CanHandle ¶
func (a *RustAdapter) CanHandle(filePath string) bool
CanHandle returns true if this adapter can handle the file
func (*RustAdapter) ExtractDefinitions ¶
func (a *RustAdapter) ExtractDefinitions(ast *models.AST) ([]*models.Definition, error)
ExtractDefinitions returns definitions from parsed AST
func (*RustAdapter) FormatTestCode ¶
func (a *RustAdapter) FormatTestCode(code string) (string, error)
FormatTestCode formats Rust test code using rustfmt
func (*RustAdapter) GenerateTestPath ¶
func (a *RustAdapter) GenerateTestPath(sourcePath string, outputDir string) string
GenerateTestPath returns the expected path for a test file
func (*RustAdapter) GetPromptTemplate ¶
func (a *RustAdapter) GetPromptTemplate(testType string) string
GetPromptTemplate returns the prompt template for Rust tests
func (*RustAdapter) ParseFile ¶
func (a *RustAdapter) ParseFile(content string) (*models.AST, error)
ParseFile parses Rust source code and extracts structure
func (*RustAdapter) RunTests ¶
func (a *RustAdapter) RunTests(testDir string) (*models.TestResults, error)
RunTests executes Rust tests and returns results
func (*RustAdapter) SelectFramework ¶
func (a *RustAdapter) SelectFramework(projectPath string) string
SelectFramework determines the test framework to use
func (*RustAdapter) ValidateTests ¶
func (a *RustAdapter) ValidateTests(testCode string, testPath string) error
ValidateTests checks if generated tests compile