Skip to content

pgtap function to check returns geom #2818

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

Conversation

cvvergara
Copy link
Member

@cvvergara cvvergara commented Apr 2, 2025

Fixes #2809 .

Changes proposed in this pull request:

  • Creating function
  • Using function
  • Cleaup of duplicated tests done by function_returns

@pgRouting/admins

Summary by CodeRabbit

  • Tests
    • Streamlined internal validations by reducing redundant test cases and simplifying checks to improve overall reliability.
    • Enforced a consistent ordering of outputs, ensuring more predictable results.
  • New Features
    • Introduced a helper utility for verifying that geometry outputs conform to expected standards.

These improvements enhance the consistency and efficiency of core functionality verifications, contributing to a more robust and reliable system.

@cvvergara cvvergara added the pgtap Related to pgtap label Apr 2, 2025
@cvvergara cvvergara added this to the Release 3.8.0 milestone Apr 2, 2025
@cvvergara cvvergara requested a review from robe2 April 2, 2025 19:23
Copy link
Contributor

coderabbitai bot commented Apr 2, 2025

Walkthrough

This pull request modifies several SQL test scripts by reducing the number of planned tests and removing specific return type validation (using set_eq) from various functions. It standardizes test behaviors by eliminating redundant checks and streamlines query operations (e.g., adding an ORDER BY clause). Additionally, a new function, function_returns_geom, has been added to verify that certain functions return a geometry type. There are no modifications to the exported or public entities in these changes.

Changes

File(s) Change Summary
pgtap/chinese/chinesePostmanCost/types_check.pg, pgtap/max_flow/maxFlow/types_check.pg, pgtap/max_flow/maxFlowMinCost_Cost/types_check.pg, pgtap/topology/analyzeGraph/types_check.pg, pgtap/topology/analyzeOneWay/types_check.pg, pgtap/topology/createTopology/types_check.pg, pgtap/topology/createVerticesTable/types_check.pg, pgtap/topology/nodeNetwork/types_check.pg Decreased planned test counts and removed set_eq return type checks.
pgtap/coloring/bipartite/edge_cases.pg Added ORDER BY id clause to PREPARE queries for consistent ordering.
pgtap/others/alpha_shape/types_check.pg, pgtap/planar/isPlanar/types_check.pg Simplified return type tests by replacing a CTE-based check with a direct function call and adjusting plan numbers.
tools/testers/general_pgtap_tests.sql Added new function function_returns_geom(TEXT) for verifying geometry return types.

Sequence Diagram(s)

sequenceDiagram
    participant Tester as Test Suite
    participant FRG as function_returns_geom
    participant PG as pg_proc

    Tester->>+FRG: Call function_returns_geom('function_name')
    FRG->>+PG: Query pg_proc for return type of 'function_name'
    PG-->>-FRG: Return function return type
    FRG-->>-Tester: Evaluate and return geometry verification result
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement function_returns_geom for functions returning geometry (#2809)

Suggested labels

Function/Internal, Other

Suggested reviewers

  • robe2

Poem

In the SQL garden where queries bloom,
I’m the rabbit, hopping with room to zoom.
Removed a check here, reduced tests there,
Now cleaner code makes me stop and stare.
With function_returns_geom lighting the way,
I nibble on changes in bright array! 🐇✨
Happy hops for code that’s light and gay!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f3135b1 and 7403bbf.

📒 Files selected for processing (12)
  • pgtap/chinese/chinesePostmanCost/types_check.pg (1 hunks)
  • pgtap/coloring/bipartite/edge_cases.pg (2 hunks)
  • pgtap/max_flow/maxFlow/types_check.pg (1 hunks)
  • pgtap/max_flow/maxFlowMinCost_Cost/types_check.pg (1 hunks)
  • pgtap/others/alpha_shape/types_check.pg (1 hunks)
  • pgtap/planar/isPlanar/types_check.pg (1 hunks)
  • pgtap/topology/analyzeGraph/types_check.pg (1 hunks)
  • pgtap/topology/analyzeOneWay/types_check.pg (1 hunks)
  • pgtap/topology/createTopology/types_check.pg (1 hunks)
  • pgtap/topology/createVerticesTable/types_check.pg (1 hunks)
  • pgtap/topology/nodeNetwork/types_check.pg (1 hunks)
  • tools/testers/general_pgtap_tests.sql (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (16)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Ubuntu clang
  • GitHub Check: Ubuntu Boost (83)
  • GitHub Check: Ubuntu Boost (79)
  • GitHub Check: Ubuntu Boost (86)
  • GitHub Check: Ubuntu Boost (78)
  • GitHub Check: Ubuntu Boost (84)
  • GitHub Check: Ubuntu Boost (56)
  • GitHub Check: Ubuntu Boost (80)
  • GitHub Check: Ubuntu Boost (75)
  • GitHub Check: Ubuntu Boost (68)
  • GitHub Check: Ubuntu Boost (77)
  • GitHub Check: Ubuntu Boost (76)
  • GitHub Check: macos (macos-14)
  • GitHub Check: macos (macos-latest)
  • GitHub Check: Check queries
🔇 Additional comments (13)
pgtap/topology/nodeNetwork/types_check.pg (1)

22-22: Appropriate plan reduction that aligns with test cleanup objective

Reducing the number of tests from 6 to 5 correctly reflects the removal of the redundant return type check that was using set_eq(). The remaining tests still provide thorough coverage of the function's existence, signature, and return type.

pgtap/topology/analyzeGraph/types_check.pg (1)

22-22: Appropriate plan reduction that aligns with test cleanup objective

Reducing the number of tests from 6 to 5 correctly reflects the removal of the redundant return type check that was using set_eq(). The remaining tests still provide thorough coverage of the function's existence, signature, and return type.

pgtap/others/alpha_shape/types_check.pg (1)

29-29: Good implementation of the new function_returns_geom function

This is a clean implementation of the new function_returns_geom function mentioned in the PR objectives. It simplifies the test by replacing what was likely a more verbose check involving a CTE and set_eq() to query the pg_proc table. The new approach is more readable and directly expresses the intent of checking for a geometry return type.

pgtap/topology/analyzeOneWay/types_check.pg (1)

22-22: Appropriate plan reduction that aligns with test cleanup objective

Reducing the number of tests from 6 to 5 correctly reflects the removal of the redundant return type check that was using set_eq(). The remaining tests still provide thorough coverage of the function's existence, signature, and return type.

tools/testers/general_pgtap_tests.sql (1)

101-108: Excellent addition of the function_returns_geom utility function.

This new helper function is well-structured and follows the same pattern as the existing utility functions. It properly extracts the return type from pg_proc and checks if it matches 'geometry'. This will help standardize geometry type checking across multiple test files and reduce code duplication.

pgtap/topology/createTopology/types_check.pg (1)

22-22: Correctly adjusted the test plan count.

The reduction from 6 to 5 planned tests accurately reflects the actual number of tests being performed after removing the redundant return type check. This change is consistent with the PR objective of cleaning up duplicated tests.

pgtap/chinese/chinesePostmanCost/types_check.pg (1)

23-23: Correctly adjusted the test plan count.

The reduction from 6 to 5 planned tests accurately reflects the actual number of tests being performed after removing the redundant return type check. This change is consistent with the PR objective of cleaning up duplicated tests while maintaining thorough function signature verification.

pgtap/max_flow/maxFlow/types_check.pg (1)

23-23: Correctly adjusted the test plan count.

The reduction from 14 to 13 planned tests accurately reflects the actual number of tests being performed after removing the redundant return type check. This change is consistent with the PR objective of cleaning up duplicated tests while maintaining thorough function signature verification across multiple overloads of the pgr_maxflow function.

pgtap/max_flow/maxFlowMinCost_Cost/types_check.pg (1)

22-22: Test plan updated to reflect removal of redundant check.

The number of planned tests has been decreased from 14 to 13, which correctly reflects the removal of the redundant return type check that was previously using set_eq.

pgtap/coloring/bipartite/edge_cases.pg (2)

103-103: Improved test determinism with ORDER BY clause.

Adding the ORDER BY id clause ensures consistent and deterministic results when testing, which is especially important for reliable set comparisons in test assertions.


123-123: Improved test determinism with ORDER BY clause.

Similar to the previous query, adding the ORDER BY id clause ensures consistent and predictable result ordering, making the tests more reliable across different database states.

pgtap/planar/isPlanar/types_check.pg (1)

22-22: Test plan adjusted to reflect removed check.

The number of planned tests has been decreased from 5 to 4 when the minimum version is 3.2.0, correctly matching the removal of the redundant return type check.

pgtap/topology/createVerticesTable/types_check.pg (1)

22-22: Test plan updated to reflect removal of redundant check.

The number of planned tests has been decreased from 6 to 5, which correctly reflects the removal of the redundant return type check that was previously using set_eq.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@cvvergara cvvergara merged commit fc7dc91 into pgRouting:main Apr 2, 2025
23 checks passed
@cvvergara cvvergara deleted the issue-2809-function-returns-geom branch April 2, 2025 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pgtap Related to pgtap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

function_returns_geom for pgtap tests
2 participants