Skip to content

Commit 7b7e020

Browse files
committed
Fix unit test, by adding a fixed restrict key for pgdump output comparison
1 parent bd40c7b commit 7b7e020

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

cmd/pg-schema-diff/apply_cmd_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ func (suite *cmdTestSuite) TestApplyCmd() {
7878
})
7979
// The migration should have been successful. Assert it was.
8080
expectedDb := tempDbWithSchema(suite.T(), suite.pgEngine, tc.expectedSchemaDDL)
81-
expectedDbDump, err := pgdump.GetDump(expectedDb, pgdump.WithSchemaOnly())
81+
expectedDbDump, err := pgdump.GetDump(expectedDb, pgdump.WithSchemaOnly(), pgdump.WithRestrictKey("test"))
8282
suite.Require().NoError(err)
83-
fromDbDump, err := pgdump.GetDump(fromDb, pgdump.WithSchemaOnly())
83+
fromDbDump, err := pgdump.GetDump(fromDb, pgdump.WithSchemaOnly(), pgdump.WithRestrictKey("test"))
8484
suite.Require().NoError(err)
8585

8686
suite.Equal(expectedDbDump, fromDbDump)

internal/pgdump/dump.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ func WithSchemaOnly() Parameter {
2626
}
2727
}
2828

29+
func WithRestrictKey(restrict_key string) Parameter {
30+
return Parameter{
31+
values: []string{"--restrict-key", restrict_key},
32+
}
33+
}
34+
2935
// GetDump gets the pg_dump of the inputted database.
3036
// It is only intended to be used for testing. You cannot securely pass passwords with this implementation, so it will
3137
// only accept databases created for unit tests (spun up with the pgengine package)

0 commit comments

Comments
 (0)