Skip to content
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

Enable using the list command on unit tests #9480

Merged
merged 8 commits into from
Feb 5, 2024
Merged

Conversation

gshank
Copy link
Contributor

@gshank gshank commented Jan 29, 2024

resolves #8508

Problem

Users want to be able to list their unit tests.

Solution

Update the list command to handle listing unit tests

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX
  • This PR includes type annotations for new and modified functions

@gshank gshank requested a review from a team as a code owner January 29, 2024 16:50
@gshank gshank requested a review from emmyoop January 29, 2024 16:50
@cla-bot cla-bot bot added the cla:yes label Jan 29, 2024
Copy link

codecov bot commented Jan 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5ae8f6a) 87.90% compared to head (55b8df2) 87.97%.
Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9480      +/-   ##
==========================================
+ Coverage   87.90%   87.97%   +0.06%     
==========================================
  Files         164      167       +3     
  Lines       22076    22160      +84     
==========================================
+ Hits        19407    19496      +89     
+ Misses       2669     2664       -5     
Flag Coverage Δ
integration 85.45% <100.00%> (+0.05%) ⬆️
unit 62.32% <13.04%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

core/dbt/task/list.py Outdated Show resolved Hide resolved
@@ -113,6 +113,8 @@ def generate_selectors(self):
elif node.resource_type == NodeType.Unit:
assert isinstance(node, UnitTestDefinition)
unit_test_selector = ".".join([node.package_name, node.name])
if node.version:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a direct comparison to None to ensure version=0 is handled correctly.

Copy link
Contributor

@MichelleArk MichelleArk Jan 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth implementing a property on UnitTestDefinition.. maybe versioned_name? and consolidate this logic here + in formatting in test.py: https://github.com/dbt-labs/dbt-core/blob/main/core/dbt/task/test.py#L87-L88

your call!

Copy link
Contributor

@MichelleArk MichelleArk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved pending one outstanding comment re: handling v0

@gshank gshank merged commit 7885e87 into main Feb 5, 2024
51 checks passed
@gshank gshank deleted the gs/list_unit_tests branch February 5, 2024 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-3039] Ensure that list command works for unit_tests and has reasonable output
2 participants