Documentation
¶
Overview ¶
Package integration provides integration testing utilities for staghorn.
Index ¶
- func ApplySetup(env *TestEnv, setup FixtureSetup) error
- type Asserter
- func (a *Asserter) ContainsSection(header string) bool
- func (a *Asserter) ContainsText(text string) bool
- func (a *Asserter) GetContent() string
- func (a *Asserter) HasManagedHeader() bool
- func (a *Asserter) HasProvenanceMarker(source string) bool
- func (a *Asserter) HasSourceRepo(repo string) bool
- func (a *Asserter) ProvenanceOrder() []string
- func (a *Asserter) RunAssertions(assertions FixtureAssertions)
- type ConfigSetup
- type Fixture
- type FixtureAssertions
- type FixtureSetup
- type HeaderAssertion
- type LanguageCheck
- type LanguagesSetup
- type MultiSourceRepo
- type PersonalSetup
- type ProvenanceCheck
- type SourceConfigSetup
- type TeamSetup
- type TestEnv
- func (e *TestEnv) Cleanup()
- func (e *TestEnv) GetClaudeRulesDir() string
- func (e *TestEnv) GetClaudeSkillsDir() string
- func (e *TestEnv) GetOutputPath() string
- func (e *TestEnv) ReadClaudeRule(relPath string) (string, error)
- func (e *TestEnv) ReadClaudeSkill(skillName string) (string, error)
- func (e *TestEnv) ReadClaudeSkillFile(skillName, relPath string) (string, error)
- func (e *TestEnv) ReadOutput() (string, error)
- func (e *TestEnv) RunMultiSourceSync(cfg *config.Config) error
- func (e *TestEnv) RunSync(owner, repo string, cfg *config.Config) error
- func (e *TestEnv) RunSyncRules(owner, repo string) (int, error)
- func (e *TestEnv) RunSyncSkills(owner, repo string) (int, error)
- func (e *TestEnv) RunSyncSkillsMultiSource(cfg *config.Config) (int, error)
- func (e *TestEnv) SetupConfig(cfg *config.Config) error
- func (e *TestEnv) SetupExistingClaudeSkill(skillName, skillMD string) error
- func (e *TestEnv) SetupPersonalConfig(content string) error
- func (e *TestEnv) SetupPersonalLanguage(lang, content string) error
- func (e *TestEnv) SetupPersonalRule(relPath, content string) error
- func (e *TestEnv) SetupPersonalSkill(skillName, skillMD string) error
- func (e *TestEnv) SetupTeamCommand(owner, repo, cmd, content string) error
- func (e *TestEnv) SetupTeamConfig(owner, repo, content string) error
- func (e *TestEnv) SetupTeamLanguage(owner, repo, lang, content string) error
- func (e *TestEnv) SetupTeamRule(owner, repo, relPath, content string) error
- func (e *TestEnv) SetupTeamSkill(owner, repo, skillName, skillMD string) error
- func (e *TestEnv) SetupTeamSkillWithFiles(owner, repo, skillName, skillMD string, files map[string]string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplySetup ¶
func ApplySetup(env *TestEnv, setup FixtureSetup) error
ApplySetup applies the fixture setup to a test environment.
Types ¶
type Asserter ¶
type Asserter struct {
// contains filtered or unexported fields
}
Asserter provides assertion helpers for CLAUDE.md output.
func NewAsserter ¶
NewAsserter creates an asserter for the given content.
func (*Asserter) ContainsSection ¶
ContainsSection checks if a ## section header exists.
func (*Asserter) ContainsText ¶
ContainsText checks if the content contains a substring.
func (*Asserter) GetContent ¶
GetContent returns the raw content.
func (*Asserter) HasManagedHeader ¶
HasManagedHeader checks for "<!-- Managed by staghorn" header.
func (*Asserter) HasProvenanceMarker ¶
HasProvenanceMarker checks for a specific provenance marker.
func (*Asserter) HasSourceRepo ¶
HasSourceRepo checks if the header contains the expected source repo.
func (*Asserter) ProvenanceOrder ¶
ProvenanceOrder returns the layers in order of appearance.
func (*Asserter) RunAssertions ¶
func (a *Asserter) RunAssertions(assertions FixtureAssertions)
RunAssertions runs all assertions from a fixture definition.
type ConfigSetup ¶
type ConfigSetup struct {
Version int `yaml:"version"`
Source interface{} `yaml:"source"` // Can be string or SourceConfigSetup
Languages *LanguagesSetup `yaml:"languages"`
}
ConfigSetup defines the staghorn config.yaml content.
func (*ConfigSetup) ToConfig ¶
func (c *ConfigSetup) ToConfig() *config.Config
ToConfig converts fixture config setup to a config.Config. It logs warnings for malformed or missing fields in the source configuration.
type Fixture ¶
type Fixture struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Setup FixtureSetup `yaml:"setup"`
Assertions FixtureAssertions `yaml:"assertions"`
}
Fixture represents a test scenario loaded from YAML.
func LoadAllFixtures ¶
LoadAllFixtures loads all fixtures from a directory.
func LoadFixture ¶
LoadFixture loads a fixture from a YAML file.
type FixtureAssertions ¶
type FixtureAssertions struct {
OutputExists bool `yaml:"output_exists"`
Header *HeaderAssertion `yaml:"header"`
Provenance *ProvenanceCheck `yaml:"provenance"`
Contains []string `yaml:"contains"`
NotContains []string `yaml:"not_contains"`
Sections []string `yaml:"sections"`
Languages []LanguageCheck `yaml:"languages"`
}
FixtureAssertions defines what to verify.
type FixtureSetup ¶
type FixtureSetup struct {
Team *TeamSetup `yaml:"team"`
MultiSource []MultiSourceRepo `yaml:"multi_source,omitempty"`
Personal *PersonalSetup `yaml:"personal"`
Config *ConfigSetup `yaml:"config"`
}
FixtureSetup defines the test environment setup.
type HeaderAssertion ¶
type HeaderAssertion struct {
ManagedBy bool `yaml:"managed_by"`
SourceRepo string `yaml:"source_repo"`
}
HeaderAssertion checks the staghorn header.
type LanguageCheck ¶
type LanguageCheck struct {
Name string `yaml:"name"`
HasTeamContent bool `yaml:"has_team_content"`
HasPersonalContent bool `yaml:"has_personal_content"`
Contains []string `yaml:"contains"`
}
LanguageCheck verifies language section content.
type LanguagesSetup ¶
type LanguagesSetup struct {
Enabled []string `yaml:"enabled"`
Disabled []string `yaml:"disabled"`
}
LanguagesSetup defines language configuration.
type MultiSourceRepo ¶
type MultiSourceRepo struct {
Source string `yaml:"source"`
ClaudeMD string `yaml:"claude_md,omitempty"`
Languages map[string]string `yaml:"languages,omitempty"`
Commands map[string]string `yaml:"commands,omitempty"`
}
MultiSourceRepo defines content from a specific repository in multi-source setup.
type PersonalSetup ¶
type PersonalSetup struct {
PersonalMD string `yaml:"personal_md"`
Languages map[string]string `yaml:"languages"`
}
PersonalSetup defines personal config files.
type ProvenanceCheck ¶
type ProvenanceCheck struct {
HasTeam bool `yaml:"has_team"`
HasPersonal bool `yaml:"has_personal"`
Order []string `yaml:"order"`
}
ProvenanceCheck verifies provenance markers.
type SourceConfigSetup ¶
type SourceConfigSetup struct {
Default string `yaml:"default"`
Base string `yaml:"base,omitempty"`
Languages map[string]string `yaml:"languages,omitempty"`
Commands map[string]string `yaml:"commands,omitempty"`
}
SourceConfigSetup defines multi-source configuration in fixtures.
type TeamSetup ¶
type TeamSetup struct {
Source string `yaml:"source"`
ClaudeMD string `yaml:"claude_md"`
Languages map[string]string `yaml:"languages"`
}
TeamSetup simulates the team repo content.
type TestEnv ¶
type TestEnv struct {
RootDir string // t.TempDir() root
HomeDir string // Simulated $HOME
ConfigDir string // ~/.config/staghorn
CacheDir string // ~/.cache/staghorn
ClaudeDir string // ~/.claude
Paths *config.Paths // Configured paths pointing to temp dirs
// contains filtered or unexported fields
}
TestEnv provides an isolated test environment with overridden paths.
func NewTestEnv ¶
NewTestEnv creates an isolated test environment. All paths are configured to use temporary directories.
func (*TestEnv) Cleanup ¶
func (e *TestEnv) Cleanup()
Cleanup is a no-op retained for API compatibility. Temporary directories are automatically cleaned up by t.TempDir().
func (*TestEnv) GetClaudeRulesDir ¶
GetClaudeRulesDir returns the path to ~/.claude/rules.
func (*TestEnv) GetClaudeSkillsDir ¶
GetClaudeSkillsDir returns the path to ~/.claude/skills.
func (*TestEnv) GetOutputPath ¶
GetOutputPath returns the path to ~/.claude/CLAUDE.md.
func (*TestEnv) ReadClaudeRule ¶
ReadClaudeRule reads a rule from ~/.claude/rules.
func (*TestEnv) ReadClaudeSkill ¶
ReadClaudeSkill reads SKILL.md from ~/.claude/skills/<name>/.
func (*TestEnv) ReadClaudeSkillFile ¶
ReadClaudeSkillFile reads a supporting file from a Claude skill directory.
func (*TestEnv) ReadOutput ¶
ReadOutput reads the final CLAUDE.md output.
func (*TestEnv) RunMultiSourceSync ¶
RunMultiSourceSync executes the merge for multi-source configurations. It reads the base config from the base repo and languages from their respective repos.
func (*TestEnv) RunSync ¶
RunSync executes the merge and write operation with the current test environment. This replicates the core logic of applyConfig without the interactive prompts.
func (*TestEnv) RunSyncRules ¶
RunSyncRules syncs rules from team/personal sources to Claude rules directory.
func (*TestEnv) RunSyncSkills ¶
RunSyncSkills syncs skills from team/personal sources to Claude skills directory.
func (*TestEnv) RunSyncSkillsMultiSource ¶
RunSyncSkillsMultiSource syncs skills from multiple source repos.
func (*TestEnv) SetupConfig ¶
SetupConfig writes config.yaml.
func (*TestEnv) SetupExistingClaudeSkill ¶
SetupExistingClaudeSkill creates a skill in ~/.claude/skills that is NOT managed by staghorn. Used for testing collision detection.
func (*TestEnv) SetupPersonalConfig ¶
SetupPersonalConfig writes personal.md.
func (*TestEnv) SetupPersonalLanguage ¶
SetupPersonalLanguage writes a personal language config.
func (*TestEnv) SetupPersonalRule ¶
SetupPersonalRule writes a personal rule.
func (*TestEnv) SetupPersonalSkill ¶
SetupPersonalSkill writes a personal skill.
func (*TestEnv) SetupTeamCommand ¶
SetupTeamCommand writes a team command to cache.
func (*TestEnv) SetupTeamConfig ¶
SetupTeamConfig writes team CLAUDE.md to cache (simulates fetch).
func (*TestEnv) SetupTeamLanguage ¶
SetupTeamLanguage writes a team language config to cache.
func (*TestEnv) SetupTeamRule ¶
SetupTeamRule writes a team rule to cache.
func (*TestEnv) SetupTeamSkill ¶
SetupTeamSkill writes a team skill to cache. The skill is a directory containing SKILL.md and optional supporting files.