test

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 3 Imported by: 0

README

Integration Testing Framework

End-to-end testing of the YAML-to-SQL pipeline with snapshot-based regression testing.

Core Function

func AssertSQLDiff(t *testing.T, current, wanted *loader.DesiredState, snapshotPath string)

Compares database states, generates SQL, and validates against snapshots.

Usage

// Prepare states
current := loader.NewDesiredState()  // Empty database
wanted := loader.NewDesiredState()   // Database with events table
wanted.Tables["events"] = eventsTable

// Test SQL generation
AssertSQLDiff(t, current, wanted, "testdata/snapshots/events_create.sql")

Test Scenarios

  • TestIntegration_EventsTable_CreateSQL - Create single table
  • TestIntegration_BothTables_CreateSQL - Create multiple tables
  • TestIntegration_DropTable_SQL - Drop table

Running Tests

# Run tests
go test ./test -v

# Update snapshots when SQL generation changes
go test ./test -update-snapshots

Snapshots

Located in testdata/snapshots/:

  • events_create.sql - Single table creation
  • both_tables_create.sql - Multiple tables
  • events_drop.sql - Table deletion

Snapshots contain expected SQL output and serve as regression protection.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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