test

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UpdateTranslationTestCases

func UpdateTranslationTestCases(mapper pgsql.KindMapper) error

UpdateTranslationTestCases regenerates SQL golden files from their embedded Cypher cases.

Types

type TranslationTestCase

type TranslationTestCase struct {
	// Name identifies the fixture within its source file.
	Name string
	// Cypher is the source query supplied to the frontend.
	Cypher string
	// PgSQL is the expected rendered PostgreSQL statement.
	PgSQL string
	// CypherParams contains dynamic caller parameters keyed by Cypher symbol.
	CypherParams map[string]any
	// PgSQLParams contains the expected dynamic SQL parameter bindings.
	PgSQLParams map[string]any
}

TranslationTestCase pairs a Cypher query and dynamic parameters with the expected PostgreSQL translation.

func ReadTranslationTestCases

func ReadTranslationTestCases() ([]*TranslationTestCase, error)

func (*TranslationTestCase) Assert

func (s *TranslationTestCase) Assert(t *testing.T, expectedSQL string, kindMapper pgsql.KindMapper)

Assert translates the case and compares normalized SQL and parameters with the golden expectations.

func (*TranslationTestCase) AssertLive

func (s *TranslationTestCase) AssertLive(ctx context.Context, t *testing.T, driver *pg.Driver)

func (*TranslationTestCase) Copy

Copy duplicates the fixture record while retaining its parameter map references.

func (*TranslationTestCase) Reset

func (s *TranslationTestCase) Reset()

Reset clears the fixture fields so the parser can accumulate the next case.

func (*TranslationTestCase) WriteTo

func (s *TranslationTestCase) WriteTo(output io.Writer, kindMapper pgsql.KindMapper) error

WriteTo parses and translates the query, then writes its source, parameters, and SQL fixture text.

type TranslationTestCaseFile

type TranslationTestCaseFile struct {
	// contains filtered or unexported fields
}

func ReadTranslationTestCaseFile

func ReadTranslationTestCaseFile(path string, fin fs.File) (TranslationTestCaseFile, error)

func (*TranslationTestCaseFile) Load

Jump to

Keyboard shortcuts

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