-
Notifications
You must be signed in to change notification settings - Fork 30
chore: skip pg_get_viewdef related test for PG 14, 15 #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d440627
Revert "fix: normalize view definitions for PostgreSQL 14-15 compatib…
tianzhou c0ad1f8
feat: add version-specific test skipping for PostgreSQL 14-15
tianzhou e688a39
refactor: simplify skip logic to use exact match only
tianzhou 92d8bcf
refactor: deduplicate skip list for PG 14-15
tianzhou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| // Package testutil provides shared test utilities for pgschema | ||
| package testutil | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
| ) | ||
|
|
||
| // skipListPG14_15 defines test cases that should be skipped for PostgreSQL 14-15. | ||
| // | ||
| // Reason for skipping: | ||
| // PostgreSQL 14-15 use pg_get_viewdef() which returns table-qualified column names (e.g., employees.id), | ||
| // while PostgreSQL 16+ returns simplified column names (e.g., id). This is a non-consequential | ||
| // formatting difference that does not impact correctness, but causes test comparison failures. | ||
| var skipListPG14_15 = []string{ | ||
| // View tests - pg_get_viewdef() formatting differences | ||
| "create_view/add_view", | ||
| "create_view/alter_view", | ||
| "create_view/drop_view", | ||
|
|
||
| // Materialized view tests - same pg_get_viewdef() issue | ||
| "create_materialized_view/add_materialized_view", | ||
| "create_materialized_view/alter_materialized_view", | ||
| "create_materialized_view/drop_materialized_view", | ||
|
|
||
| // Online materialized view index tests - depend on materialized view definitions | ||
| "online/add_materialized_view_index", | ||
| "online/alter_materialized_view_index", | ||
|
|
||
| // Comment tests - fingerprint includes view definitions | ||
| "comment/add_index_comment", | ||
| "comment/add_view_comment", | ||
|
|
||
| // Index tests - fingerprint includes view definitions | ||
| "create_index/drop_index", | ||
|
|
||
| // Migration tests - include views and materialized views | ||
| "migrate/v4", | ||
| "migrate/v5", | ||
|
|
||
| // Dump integration tests - contain views with formatting differences | ||
| "TestDumpCommand_Employee", | ||
| "TestDumpCommand_Issue82ViewLogicExpr", | ||
|
|
||
| // Include integration test - uses materialized views | ||
| "TestIncludeIntegration", | ||
| } | ||
|
|
||
| // skipListForVersion maps PostgreSQL major versions to their skip lists. | ||
| var skipListForVersion = map[int][]string{ | ||
| 14: skipListPG14_15, | ||
| 15: skipListPG14_15, | ||
| } | ||
|
|
||
| // ShouldSkipTest checks if a test should be skipped for the given PostgreSQL major version. | ||
| // If the test should be skipped, it calls t.Skipf() which stops test execution. | ||
| // | ||
| // Test name format examples: | ||
| // - "create_view_add_view" (from TestDiffFromFiles subtests - underscores separate all parts) | ||
| // - "create_view/add_view" (skip list patterns - underscores in category, slash before test) | ||
| // - "TestDumpCommand_Employee" (from dump tests - starts with Test) | ||
| // | ||
| // Matching uses exact string match with flexible slash/underscore handling: | ||
| // Pattern "create_view/add_view" matches test name "create_view_add_view" (underscores) | ||
| func ShouldSkipTest(t *testing.T, testName string, majorVersion int) { | ||
| t.Helper() | ||
|
|
||
| // Get skip patterns for this version | ||
| skipPatterns, exists := skipListForVersion[majorVersion] | ||
| if !exists { | ||
| return // No skips defined for this version | ||
| } | ||
|
|
||
| // Check if test name matches any skip pattern (exact match) | ||
| for _, pattern := range skipPatterns { | ||
| // Convert pattern slashes to underscores to match test name format | ||
| // e.g., "create_view/add_view" -> "create_view_add_view" | ||
| patternNormalized := strings.ReplaceAll(pattern, "/", "_") | ||
tianzhou marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if testName == patternNormalized || testName == pattern { | ||
| t.Skipf("Skipping test %q on PostgreSQL %d due to pg_get_viewdef() formatting differences (non-consequential)", testName, majorVersion) | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.