aboutsummaryrefslogtreecommitdiff
path: root/pgtest/snapshot.go
blob: ed0752c1fd8121b66b9dcb7b2eff5c921624beaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// SPDX-FileCopyrightText: 2026 Stefan Majewsky <majewsky@gmx.net>
// SPDX-License-Identifier: Apache-2.0

package pgtest

import (
	"context"
	"fmt"

	"go.xyrillian.de/gg/assert"
	"go.xyrillian.de/gg/gsql"
)

// Snapshot contains a set of SQL statements.
// Instances are produced by methods of [Tracker].
type Snapshot struct {
	t assert.TestingTB
}

func newSnapshot(ctx context.Context, db gsql.Handle, topo topology) (Snapshot, error) {
	panic("TODO")
}

// 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
}