-
-
Notifications
You must be signed in to change notification settings - Fork 101
feat: add unused_replication_slot lint for stale replication slots #173
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
Draft
hunleyd
wants to merge
3
commits into
main
Choose a base branch
from
hunleyd/add-unused-replication-slot-lint
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| """Pinning tests for check_lints.py's level-column extractor. | ||
|
|
||
| Run directly: python3 bin/test_check_lints.py | ||
|
|
||
| No test framework in this repo (test/ is pg_regress only) -- assert-based, | ||
| so a future edit that re-breaks the multi-line-case guard fails loudly here | ||
| instead of only in a mutation test someone has to remember to write by hand. | ||
| """ | ||
|
|
||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| sys.path.insert(0, str(Path(__file__).parent)) | ||
| from check_lints import _level_line_error, _levels_in_lint_sql # noqa: E402 | ||
|
|
||
| CASES = { | ||
| "bare literal": ("'INFO' as level,", {"INFO"}), | ||
| "single-line case (0031's own shape)": ( | ||
| "case when prs.wal_status = 'lost' then 'ERROR' else 'WARN' end as level,", | ||
| {"ERROR", "WARN"}, | ||
| ), | ||
| "single-line nested case": ( | ||
| "case when a then 'ERROR' else case when b then 'WARN' else 'INFO' end end as level,", | ||
| {"ERROR", "WARN", "INFO"}, | ||
| ), | ||
| "multi-line case, bare end tail": ( | ||
| "case\n when a then 'ERROR'\n else 'WARN'\nend as level,", | ||
| set(), | ||
| ), | ||
| "multi-line case, value inlined on tail": ( | ||
| "case when a then 'ERROR'\n else 'WARN' end as level,", | ||
| set(), | ||
| ), | ||
| "multi-line case, nested case on tail": ( | ||
| "case when a then 'ERROR'\n else case when b then 'INFO' else 'WARN' end end as level,", | ||
| set(), | ||
| ), | ||
| "trailing comment": ("'WARN' as level, -- always warn", set()), | ||
| } | ||
|
|
||
| failures = [] | ||
| for name, (column_line, expected) in CASES.items(): | ||
| sql = f"select\n {column_line}\n y\nfrom z;" | ||
| actual = _levels_in_lint_sql(sql) | ||
| if actual != expected: | ||
| failures.append(f"{name}: expected {expected!r}, got {actual!r}") | ||
|
|
||
| # An empty sql_levels set means _level_line_error skips the comparison rather than silently passing; a doc mentioning no level word is still always an error. | ||
| if _level_line_error("WARN", set()) is not None: | ||
| failures.append( | ||
| "_level_line_error('WARN', set()) should skip comparison, not error" | ||
| ) | ||
| if _level_line_error("nothing here", set()) is None: | ||
| failures.append("_level_line_error with no level word should always error") | ||
| if _level_line_error("WARN", {"ERROR"}) is None: | ||
| failures.append("_level_line_error should error on a real mismatch") | ||
|
|
||
| if failures: | ||
| print(f"{len(failures)} pinning test(s) failed:\n") | ||
| for failure in failures: | ||
| print(f" - {failure}") | ||
| raise SystemExit(1) | ||
| print(f"all {len(CASES)} level-extraction pinning tests passed") | ||
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 |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
|
|
||
| **Level:** INFO | ||
| **Level:** ERROR | ||
|
|
||
| **Summary:** Security policy not enforced | ||
|
|
||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.