tests

package
v0.13.8-0...-a8de8dd Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dedent

func Dedent(input string) string

func InsertRawDocument

func InsertRawDocument(conn plugins.Conn, id int, filepath string, content string) error

InsertRawDocument inserts a raw_documents row with the given id so fixtures that call LoadPendingQuery directly satisfy the documents.raw_document foreign key, exactly like the extraction step does in production.

func PrintExpectedDocument

func PrintExpectedDocument(doc *ExpectedDocument) string

PrintExpectedDocument returns the GraphQL string representation of the given ExpectedDocument.

func PrintExpectedSelection

func PrintExpectedSelection(sel ExpectedSelection) string

func RunTable

func RunTable[PluginConfig any, PluginType plugins.HoudiniPlugin[PluginConfig]](
	t *testing.T,
	table Table[PluginConfig, PluginType],
)

func StrPtr

func StrPtr(s string) *string

func ValidateExpectedDocuments

func ValidateExpectedDocuments[PluginConfig any](
	t *testing.T,
	db plugins.DatabasePool[PluginConfig],
	expectedDocs []ExpectedDocument,
)

func WriteDatabaseSchema

func WriteDatabaseSchema(conn plugins.Conn) error

WriteDatabaseSchema creates the database schema.

Types

type ExpectedArgument

type ExpectedArgument struct {
	ID    int64
	Name  string
	Value *ExpectedArgumentValue
}

type ExpectedArgumentValue

type ExpectedArgumentValue struct {
	Kind     string
	Raw      string
	Children []ExpectedArgumentValueChildren
}

type ExpectedArgumentValueChildren

type ExpectedArgumentValueChildren struct {
	Name  string
	Value *ExpectedArgumentValue
}

type ExpectedDirective

type ExpectedDirective struct {
	Name      string
	Arguments []ExpectedDirectiveArgument
}

type ExpectedDirectiveArgument

type ExpectedDirectiveArgument struct {
	Name  string
	Value *ExpectedArgumentValue
}

type ExpectedDocument

type ExpectedDocument struct {
	Name          string
	RawDocument   int
	Kind          string // "query", "mutation", "subscription", or "fragment"
	TypeCondition *string
	Variables     []ExpectedOperationVariable
	Selections    []ExpectedSelection
	Directives    []ExpectedDirective
}

expectedDocument represents an operation or fragment definition.

func ExpectedDoc

func ExpectedDoc(query string) ExpectedDocument

ExpectedDoc parses a GraphQL query string and returns a slice of ExpectedDocument.

func (ExpectedDocument) WithVariables

type ExpectedOperationVariable

type ExpectedOperationVariable struct {
	Document      int
	Name          string
	Type          string
	TypeModifiers string
	DefaultValue  *ExpectedArgumentValue
	Directives    []ExpectedDirective
}

type ExpectedSelection

type ExpectedSelection struct {
	ID         int64
	FieldName  string
	Alias      *string
	PathIndex  int
	Kind       string // "field", "fragment", "inline_fragment", etc.
	Arguments  []ExpectedArgument
	Directives []ExpectedDirective
	Children   []ExpectedSelection
}

type Plugin

type Plugin[PluginConfig any] struct {
	Name                 string
	Hooks                []string
	IncludeRuntime       string
	IncludeStaticRuntime string
	Config               PluginConfig
}

type Table

type Table[PluginConfig any, PluginType plugins.HoudiniPlugin[PluginConfig]] struct {
	Schema        string
	ProjectConfig plugins.ProjectConfig
	Tests         []Test[PluginConfig]
	Plugin        Plugin[PluginConfig]
	SetupTest     func(t *testing.T, plugin PluginType, test Test[PluginConfig])
	PerformTest   func(t *testing.T, plugin PluginType, test Test[PluginConfig])
	VerifyTest    func(t *testing.T, plugin PluginType, test Test[PluginConfig])
	// SetupAlwaysPasses requires AfterExtract to succeed regardless of test.Pass.
	// Use this when test.Pass controls only PerformTest behavior (e.g. manifest
	// validation), not whether the pipeline setup itself is expected to fail.
	SetupAlwaysPasses bool
}

type Test

type Test[PluginConfig any] struct {
	Name          string
	Pass          bool
	Input         []string
	Filepaths     []string // optional per-document filepaths, parallel to Input
	Expected      []ExpectedDocument
	Extra         map[string]any
	ProjectConfig func(config *plugins.ProjectConfig)
	// substrings that must appear in the pipeline's error output. use on failing
	// tests to assert the user sees the intended validation message rather than
	// an opaque internal failure (a constraint violation, for example). asserted
	// against errors from every stage: the harness's own extract/validate setup
	// and the stages run by the default PerformTest.
	ExpectedErrors []string
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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