testgen

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package testgen generates AI-produced test suites for completed PM tasks. It reads the task artifact output, detects the project language, asks the provider to write appropriate tests, and writes them to .cloop/tests/.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildPrompt

func BuildPrompt(task *pm.Task, artifactContent string, lang Lang) string

BuildPrompt constructs the AI prompt for test generation. Exported for independent testing.

func TestFileExt

func TestFileExt(lang Lang) string

TestFileExt returns the file extension (without leading dot) for the given Lang.

Types

type Lang

type Lang string

Lang represents the detected project / task language.

const (
	LangGo     Lang = "go"
	LangPython Lang = "python"
	LangNode   Lang = "node"
	LangShell  Lang = "shell"
)

func DetectLang

func DetectLang(workDir string) Lang

DetectLang probes workDir for project files and returns the best matching Lang. Priority: go.mod > package.json > *.py files > shell (fallback).

type Result

type Result struct {
	Lang     Lang
	FilePath string // absolute path where tests were written
	Code     string // raw test code written
	Ran      bool   // true if --run was used
	Output   string // combined stdout+stderr when Ran == true
	ExitCode int    // 0 = all tests passed
}

Result holds the output of a test generation run.

func Generate

func Generate(ctx context.Context, prov provider.Provider, opts provider.Options, workDir string, task *pm.Task, lang Lang) (*Result, error)

Generate calls the AI provider to produce a test suite, writes it to .cloop/tests/<task-id>_test.<ext>, and returns a Result.

Jump to

Keyboard shortcuts

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