Documentation ¶
Overview ¶
Package utgen is a service that generates unit tests for a given source code file.
Index ¶
- Constants
- func GetCodeLanguage(sourceFilePath string) string
- func GetPackageName(sourceFilePath string) (string, error)
- func RunCommand(command string, cwd string, logger *zap.Logger) (stdout string, stderr string, exitCode int, commandStartTime int64, err error)
- func TrimParentFolder(path string) string
- type AIClient
- type AIRequest
- type AIResponse
- type Choice
- type CompletionParams
- type CompletionResponse
- type Coverage
- type CoverageProcessor
- func (cp *CoverageProcessor) ParseCoverageReport() (*models.CoverageResult, error)
- func (cp *CoverageProcessor) ParseCoverageReportCobertura() (*models.CoverageResult, error)
- func (cp *CoverageProcessor) ParseCoverageReportJacoco() (*models.CoverageResult, error)
- func (cp *CoverageProcessor) ProcessCoverageReport(latestTime int64) (*models.CoverageResult, error)
- func (cp *CoverageProcessor) VerifyReportUpdate(latestTime int64) error
- type Cursor
- type Delta
- type Injector
- type Message
- type ModelResponse
- type Prompt
- type PromptBuilder
- type PurposeType
- type ResponseChunk
- type Service
- type Source
- type Telemetry
- type Test
- type UnitTestGenerator
- func (g *UnitTestGenerator) GenerateTests(ctx context.Context, iterationCount int) (*models.UTDetails, error)
- func (g *UnitTestGenerator) Start(ctx context.Context) error
- func (g *UnitTestGenerator) ValidateTest(generatedTest models.UT, passedTests, noCoverageTest, failedBuild *int, ...) (bool, error)
- type Usage
- type UsageData
Constants ¶
View Source
const ADDITIONAL_INCLUDES_TEXT = `` /* 217-byte string literal not displayed */
View Source
const ADDITIONAL_INSTRUCTIONS_TEXT = `
## Additional Instructions
======
{{.AdditionalInstructions}}
======
`
View Source
const FAILED_TESTS_TEXT = `` /* 250-byte string literal not displayed */
View Source
const MAX_TESTS_PER_RUN = 6
Variables ¶
This section is empty.
Functions ¶
func GetCodeLanguage ¶
func GetPackageName ¶
func RunCommand ¶
func TrimParentFolder ¶
Types ¶
type AIClient ¶
type AIClient struct { Model string APIBase string APIVersion string APIKey string APIServerURL string Auth service.Auth Logger *zap.Logger SessionID string FunctionUnderTest string }
func NewAIClient ¶
type AIRequest ¶
type AIRequest struct { MaxTokens int `json:"maxTokens"` Prompt Prompt `json:"prompt"` SessionID string `json:"sessionId"` Iteration int `json:"iteration"` RequestPurpose PurposeType `json:"requestPurpose"` }
type AIResponse ¶
type CompletionParams ¶
type CompletionResponse ¶
type CoverageProcessor ¶
CoverageProcessor handles the processing of coverage reports
func NewCoverageProcessor ¶
func NewCoverageProcessor(reportPath, srcpath, format string) *CoverageProcessor
NewCoverageProcessor initializes a CoverageProcessor object
func (*CoverageProcessor) ParseCoverageReport ¶
func (cp *CoverageProcessor) ParseCoverageReport() (*models.CoverageResult, error)
ParseCoverageReport parses the coverage report based on its type
func (*CoverageProcessor) ParseCoverageReportCobertura ¶
func (cp *CoverageProcessor) ParseCoverageReportCobertura() (*models.CoverageResult, error)
func (*CoverageProcessor) ParseCoverageReportJacoco ¶
func (cp *CoverageProcessor) ParseCoverageReportJacoco() (*models.CoverageResult, error)
func (*CoverageProcessor) ProcessCoverageReport ¶
func (cp *CoverageProcessor) ProcessCoverageReport(latestTime int64) (*models.CoverageResult, error)
ProcessCoverageReport verifies the report and parses it based on its type
func (*CoverageProcessor) VerifyReportUpdate ¶
func (cp *CoverageProcessor) VerifyReportUpdate(latestTime int64) error
VerifyReportUpdate verifies the coverage report's existence and update time
type ModelResponse ¶
type PromptBuilder ¶
type PromptBuilder struct { Src *Source Test *Test CovReportContent string IncludedFiles string AdditionalInstructions string Language string Logger *zap.Logger AdditionalPrompt string InstalledPackages []string FunctionUnderTest string ImportDetails string ModuleName string }
func NewPromptBuilder ¶
func NewPromptBuilder(srcPath, testPath, covReportContent, includedFiles, additionalInstructions, language, additionalPrompt, functionUnderTest string, logger *zap.Logger) (*PromptBuilder, error)
func (*PromptBuilder) BuildPrompt ¶
func (pb *PromptBuilder) BuildPrompt(file, failedTestRuns string) (*Prompt, error)
type PurposeType ¶
type PurposeType string
PurposeType defines the type of purpose for the AI request.
const ( // TestForFunction represents a purpose type where the request is to test a function. TestForFunction PurposeType = "TestForFunction" // TestForFile represents a purpose type where the request is to test a file. TestForFile PurposeType = "TestForFile" )
type ResponseChunk ¶
type ResponseChunk struct {
Choices []Choice `json:"choices"`
}
type UnitTestGenerator ¶
type UnitTestGenerator struct { Files []string // contains filtered or unexported fields }
func NewUnitTestGenerator ¶
func (*UnitTestGenerator) GenerateTests ¶
func (*UnitTestGenerator) ValidateTest ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.