Documentation
¶
Overview ¶
Package testutil provides reusable test utilities for Raven integration tests.
Index ¶
- func BuildCLI(t *testing.T) string
- func MinimalSchema() string
- func PersonProjectSchema() string
- type BuildError
- type CLIError
- type CLIMeta
- type CLIResult
- func (r *CLIResult) AssertHasWarning(t *testing.T, code string)
- func (r *CLIResult) AssertNoWarnings(t *testing.T)
- func (r *CLIResult) AssertResultCount(t *testing.T, key string, expected int)
- func (r *CLIResult) DataList(key string) []interface{}
- func (r *CLIResult) DataString(key string) string
- func (r *CLIResult) MustFail(t *testing.T, expectedCode string) *CLIResult
- func (r *CLIResult) MustFailWithMessage(t *testing.T, msgSubstr string) *CLIResult
- func (r *CLIResult) MustSucceed(t *testing.T) *CLIResult
- type CLIWarning
- type TestVault
- func (v *TestVault) AssertBacklinks(objectID string, expectedCount int)
- func (v *TestVault) AssertDirExists(relPath string)
- func (v *TestVault) AssertFileContains(relPath, substr string)
- func (v *TestVault) AssertFileExists(relPath string)
- func (v *TestVault) AssertFileNotContains(relPath, substr string)
- func (v *TestVault) AssertFileNotExists(relPath string)
- func (v *TestVault) AssertObjectExists(objectID string)
- func (v *TestVault) AssertObjectNotExists(objectID string)
- func (v *TestVault) AssertQueryCount(query string, expectedCount int)
- func (v *TestVault) Build() *TestVault
- func (v *TestVault) FileExists(relPath string) bool
- func (v *TestVault) ReadFile(relPath string) string
- func (v *TestVault) RunCLI(args ...string) *CLIResult
- func (v *TestVault) RunCLIWithStdin(stdin string, args ...string) *CLIResult
- func (v *TestVault) WithFile(path, content string) *TestVault
- func (v *TestVault) WithRavenYAML(yaml string) *TestVault
- func (v *TestVault) WithSchema(yaml string) *TestVault
- func (v *TestVault) WriteFile(relPath, content string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildCLI ¶
BuildCLI builds the rvn binary and returns its path. This is called automatically by RunCLI but can be called explicitly if you need the binary path for other purposes.
func MinimalSchema ¶
func MinimalSchema() string
MinimalSchema returns a minimal valid schema.yaml content.
func PersonProjectSchema ¶
func PersonProjectSchema() string
PersonProjectSchema returns a schema with person and project types.
Types ¶
type BuildError ¶
BuildError represents an error building the CLI binary.
func (*BuildError) Error ¶
func (e *BuildError) Error() string
type CLIError ¶
type CLIError struct {
Code string `json:"code"`
Message string `json:"message"`
Details map[string]interface{} `json:"details,omitempty"`
Suggestion string `json:"suggestion,omitempty"`
}
CLIError represents a structured error from the CLI.
type CLIMeta ¶
type CLIMeta struct {
Count int `json:"count,omitempty"`
QueryTimeMs int64 `json:"query_time_ms,omitempty"`
}
CLIMeta contains metadata from the response.
type CLIResult ¶
type CLIResult struct {
OK bool
Data map[string]interface{}
Error *CLIError
Warnings []CLIWarning
Meta *CLIMeta
RawJSON string
ExitCode int
}
CLIResult represents the result of running a CLI command.
func (*CLIResult) AssertHasWarning ¶
AssertHasWarning checks that the result contains a warning with the given code.
func (*CLIResult) AssertNoWarnings ¶
AssertNoWarnings checks that the result has no warnings.
func (*CLIResult) AssertResultCount ¶
AssertResultCount checks that a query result has the expected count.
func (*CLIResult) DataString ¶
DataString extracts a string from the Data field.
func (*CLIResult) MustFail ¶
MustFail fails the test if the CLI command did not fail with the expected code.
func (*CLIResult) MustFailWithMessage ¶
MustFailWithMessage fails the test if the CLI command succeeded, or if it failed without an error message containing the expected substring.
type CLIWarning ¶
CLIWarning represents a warning from the CLI.
type TestVault ¶
type TestVault struct {
Path string
// contains filtered or unexported fields
}
TestVault represents a temporary vault for testing.
func NewTestVault ¶
NewTestVault creates a new test vault builder. Call Build() to create the actual vault directory.
func (*TestVault) AssertBacklinks ¶
AssertBacklinks verifies that an object has the expected number of backlinks.
func (*TestVault) AssertDirExists ¶
AssertDirExists fails the test if the directory does not exist.
func (*TestVault) AssertFileContains ¶
AssertFileContains fails the test if the file does not contain the substring.
func (*TestVault) AssertFileExists ¶
AssertFileExists fails the test if the file does not exist.
func (*TestVault) AssertFileNotContains ¶
AssertFileNotContains fails the test if the file contains the substring.
func (*TestVault) AssertFileNotExists ¶
AssertFileNotExists fails the test if the file exists.
func (*TestVault) AssertObjectExists ¶
AssertObjectExists runs a query to check if an object exists by ID.
func (*TestVault) AssertObjectNotExists ¶
AssertObjectNotExists runs a query to check that an object does not exist.
func (*TestVault) AssertQueryCount ¶
AssertQueryCount runs a query and verifies the result count.
func (*TestVault) Build ¶
Build creates the vault directory and all configured files. Returns the TestVault for method chaining.
func (*TestVault) FileExists ¶
FileExists checks if a file exists in the vault.
func (*TestVault) RunCLI ¶
RunCLI executes a CLI command against the vault and returns the parsed result. Commands are run with --json flag automatically.
func (*TestVault) RunCLIWithStdin ¶
RunCLIWithStdin executes a CLI command with stdin input.
func (*TestVault) WithFile ¶
WithFile adds a file to the vault. The path is relative to the vault root.
func (*TestVault) WithRavenYAML ¶
WithRavenYAML sets the raven.yaml content for the vault.
func (*TestVault) WithSchema ¶
WithSchema sets the schema.yaml content for the vault.