Skip to content

Commit 37790e9

Browse files
mason-sharpclaude
andcommitted
tests: use explicit skipped table in schema-diff summary test
Add a dedicated table to verify the skipped section rather than relying on ambient tables from other tests. Assert on the specific table name within the skipped section. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2c94873 commit 37790e9

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

tests/integration/schema_diff_summary_test.go

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ func TestSchemaDiff_Summary(t *testing.T) {
4545
divergentTable = "summary_divergent_tbl"
4646
noPKTable = "summary_nopk_tbl"
4747
n1OnlyTable = "summary_n1only_tbl"
48+
skippedTable = "summary_skipped_tbl"
4849
)
4950

5051
ourTables := map[string]bool{
5152
matchingTable: true,
5253
divergentTable: true,
5354
noPKTable: true,
5455
n1OnlyTable: true,
56+
skippedTable: true,
5557
}
5658

5759
// --- Create matching table (identical on both nodes) ---
@@ -113,6 +115,22 @@ func TestSchemaDiff_Summary(t *testing.T) {
113115
}
114116
})
115117

118+
// --- Create table that will be explicitly skipped ---
119+
createSkippedSQL := fmt.Sprintf(`
120+
CREATE TABLE IF NOT EXISTS %s.%s (
121+
id INT PRIMARY KEY,
122+
val TEXT
123+
)`, testSchema, skippedTable)
124+
for _, pool := range []*pgxpool.Pool{pgCluster.Node1Pool, pgCluster.Node2Pool} {
125+
_, err := pool.Exec(ctx, createSkippedSQL)
126+
require.NoError(t, err)
127+
}
128+
t.Cleanup(func() {
129+
for _, pool := range []*pgxpool.Pool{pgCluster.Node1Pool, pgCluster.Node2Pool} {
130+
pool.Exec(ctx, fmt.Sprintf(`DROP TABLE IF EXISTS %s.%s CASCADE`, testSchema, skippedTable))
131+
}
132+
})
133+
116134
// --- Create table on node1 only (missing from node2) ---
117135
createN1OnlySQL := fmt.Sprintf(`
118136
CREATE TABLE IF NOT EXISTS %s.%s (
@@ -137,17 +155,13 @@ func TestSchemaDiff_Summary(t *testing.T) {
137155
task := newTestSchemaDiffTask(testSchema, nodes)
138156
task.SkipDBUpdate = true
139157

140-
// Skip tables that belong to other tests so only our tables are diffed.
141-
// Query both nodes for the union (since RunChecks now does that).
142-
skipList := ""
158+
// Skip our dedicated skipped table plus any ambient tables from other tests.
159+
skipList := skippedTable
143160
allTables := getAllTablesUnion(t,
144161
[]*pgxpool.Pool{pgCluster.Node1Pool, pgCluster.Node2Pool}, testSchema)
145162
for _, tbl := range allTables {
146163
if !ourTables[tbl] {
147-
if skipList != "" {
148-
skipList += ","
149-
}
150-
skipList += tbl
164+
skipList += "," + tbl
151165
}
152166
}
153167
task.SkipTables = skipList
@@ -180,7 +194,8 @@ func TestSchemaDiff_Summary(t *testing.T) {
180194
"matching table should appear in the identical section")
181195

182196
skippedSection := extractBetween(summarySection, "table(s) were skipped:", "table(s)")
183-
assert.NotEmpty(t, skippedSection, "should have a skipped section")
197+
assert.Contains(t, skippedSection, skippedTable,
198+
"skipped table should appear in the skipped section")
184199

185200
diffSection := extractBetween(summarySection, "table(s) have differences:", "table(s)")
186201
assert.Contains(t, diffSection, divergentTable,

0 commit comments

Comments
 (0)