Documentation
¶
Index ¶
- func UpdateTranslationTestCases(mapper pgsql.KindMapper) error
- type TranslationTestCase
- func (s *TranslationTestCase) Assert(t *testing.T, expectedSQL string, kindMapper pgsql.KindMapper)
- func (s *TranslationTestCase) AssertLive(ctx context.Context, t *testing.T, driver *pg.Driver)
- func (s *TranslationTestCase) Copy() *TranslationTestCase
- func (s *TranslationTestCase) Reset()
- func (s *TranslationTestCase) WriteTo(output io.Writer, kindMapper pgsql.KindMapper) error
- type TranslationTestCaseFile
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 (*TranslationTestCase) Copy ¶
func (s *TranslationTestCase) Copy() *TranslationTestCase
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 ¶
func (s *TranslationTestCaseFile) Load() ([]*TranslationTestCase, bool, error)
Click to show internal directories.
Click to hide internal directories.