From baab5f6fe0aafa7752f8e9ae86fc966afc18fe1a Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Wed, 5 Aug 2026 20:54:47 +0200 Subject: pgtest: import interface spec from go-bits/easypg This is only based on looking at the API documentation. As always, the implementation will be completely fresh. --- pgtest/snapshot.go | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 pgtest/snapshot.go (limited to 'pgtest/snapshot.go') diff --git a/pgtest/snapshot.go b/pgtest/snapshot.go new file mode 100644 index 0000000..f27ecec --- /dev/null +++ b/pgtest/snapshot.go @@ -0,0 +1,46 @@ +// SPDX-FileCopyrightText: 2026 Stefan Majewsky +// SPDX-License-Identifier: Apache-2.0 + +package pgtest + +import ( + "fmt" + + "go.xyrillian.de/gg/assert" +) + +// Snapshot contains a set of SQL statements. +// Instances are produced by methods of [Tracker]. +type Snapshot struct { + t assert.TestingTB +} + +// AssertEmpty is a shorthand for AssertEqual(""). +func (s Snapshot) AssertEmpty() { + s.t.Helper() + s.AssertEqual("") +} + +// AssertEqual compares the set of SQL statements to those in the given string literal. +// A test error is generated for each difference. +// +// This assertion is lenient with regards to whitespace to enable callers +// to format their string literals in a way that fits nicely in the surrounding code: +// - Leading whitespace on each line is ignored. +// - Empty lines (containing only whitespace) are ignored. +func (s Snapshot) AssertEqual(expected string) { + s.t.Helper() + panic("TODO") +} + +// AssertEqualf is a shorthand for AssertEqual(fmt.Sprintf(format, args...)). +func (s Snapshot) AssertEqualf(format string, args ...any) { + s.t.Helper() + s.AssertEqual(fmt.Sprintf(format, args...)) +} + +// Ignore is a no-op. It is commonly used like `tr.DBChanges().Ignore()`, +// to clarify that a certain set of DB changes is not asserted on. +func (s Snapshot) Ignore() { + // intentionally empty +} -- cgit v1.3.1