Skip to content

Commit e863ffd

Browse files
authored
chore: update unit tests
1 parent e18790d commit e863ffd

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

internal/db/diff/diff_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,17 @@ create schema public`)
317317
Query(migration.INSERT_MIGRATION_VERSION, "0", "test", []string{sql}).
318318
Reply("INSERT 0 1")
319319
// Run test
320-
diff, err := DiffDatabase(context.Background(), []string{"public"}, dbConfig, io.Discard, fsys, DiffSchemaMigra, conn.Intercept)
320+
diff, err := DiffDatabase(context.Background(), []string{"public"}, dbConfig, io.Discard, fsys, DiffSchemaMigra, func(cc *pgx.ConnConfig) {
321+
if cc.Host == dbConfig.Host {
322+
// Fake a SSL error when connecting to target database
323+
cc.LookupFunc = func(ctx context.Context, host string) (addrs []string, err error) {
324+
return nil, errors.New("server refused TLS connection")
325+
}
326+
} else {
327+
// Hijack connection to shadow database
328+
conn.Intercept(cc)
329+
}
330+
})
321331
// Check error
322332
assert.Empty(t, diff)
323333
assert.ErrorContains(t, err, "error diffing schema")

0 commit comments

Comments
 (0)