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

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

Closed
Tracked by #8283
gshank opened this issue Aug 28, 2023 · 2 comments · Fixed by #9480
Closed
Tracked by #8283

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

gshank opened this issue Aug 28, 2023 · 2 comments · Fixed by #9480
Assignees

Comments

@gshank
Copy link
Contributor

gshank commented Aug 28, 2023

Description

From #8651 and #8606

We should be able to list unit tests in a project using --select test_type:unit.

Acceptance Criteria

List command works for unit tests and has reasonable output.
dbt list --select test_type:unit
dbt list --select test_type:data

dbt list --resource-type test to return all data and all unit tests

Impact to other teams

None

Will backports be required?

No

Context

@github-actions github-actions bot changed the title Ensure that list command works for unit_tests and has reasonable output [CT-3039] Ensure that list command works for unit_tests and has reasonable output Aug 28, 2023
@MichelleArk
Copy link
Contributor

MichelleArk commented Nov 21, 2023

Looks like dbt list doesn't work with the test_type: resource selector as of yet:

❯ dbt build -s +my_model,test_type:unit
16:42:55  Running with dbt=1.8.0-a1
16:42:55  target not specified in profile 'postgres', using 'default'
16:42:55  Registered adapter: postgres=1.8.0-a1
16:42:55  Found 8 models, 3 seeds, 20 tests, 0 sources, 0 exposures, 0 metrics, 410 macros, 0 groups, 0 semantic models, 5 unit tests
16:42:55  
16:42:56  Concurrency: 1 threads (target='default')
16:42:56  
16:42:56  1 of 5 START unit_test test_my_model ........................................... [RUN]
16:42:56  1 of 5 PASS test_my_model ...................................................... [PASS in 0.12s]
16:42:56  2 of 5 START unit_test test_my_model_datetime .................................. [RUN]
16:42:56  2 of 5 PASS test_my_model_datetime ............................................. [PASS in 0.11s]
16:42:56  3 of 5 START unit_test test_my_model_empty ..................................... [RUN]
16:42:56  3 of 5 PASS test_my_model_empty ................................................ [PASS in 0.08s]
16:42:56  4 of 5 START unit_test test_my_model_overrides ................................. [RUN]
16:42:56  4 of 5 PASS test_my_model_overrides ............................................ [PASS in 0.07s]
16:42:56  5 of 5 START unit_test test_my_model_string_concat ............................. [RUN]
16:42:56  5 of 5 PASS test_my_model_string_concat ........................................ [PASS in 0.07s]
16:42:56  
16:42:56  Finished running 5 unit_tests in 0 hours 0 minutes and 1.00 seconds (1.00s).
16:42:56  
16:42:56  Completed successfully
16:42:56  
16:42:56  Done. PASS=5 WARN=0 ERROR=0 SKIP=0 TOTAL=5
❯ dbt ls -s +my_model,test_type:unit
16:43:05  Running with dbt=1.8.0-a1
16:43:05  target not specified in profile 'postgres', using 'default'
16:43:05  Registered adapter: postgres=1.8.0-a1
16:43:05  Found 8 models, 3 seeds, 20 tests, 0 sources, 0 exposures, 0 metrics, 410 macros, 0 groups, 0 semantic models, 5 unit tests
16:43:05  No nodes selected!
❯ dbt ls -s test_type:unit
16:48:01  Running with dbt=1.8.0-a1
16:48:01  target not specified in profile 'postgres', using 'default'
16:48:01  Registered adapter: postgres=1.8.0-a1
16:48:01  Found 8 models, 3 seeds, 20 tests, 0 sources, 0 exposures, 0 metrics, 410 macros, 0 groups, 0 semantic models, 5 unit tests
16:48:01  No nodes selected!

@dbeatty10
Copy link
Contributor

If you have a models/_models.yml file like this:

models:
  - name: my_model
    columns:
      - name: id
        tests:
          - unique
    versions:    
      - v: 1
      - v: 2

Then here is the output of dbt list:

(dbt_1.7) $ dbt ls -s +my_model,resource_type:test

00:41:29  Running with dbt=1.7.4
00:41:30  Registered adapter: postgres=1.7.4
00:41:30  Found 3 models, 1 snapshot, 1 analysis, 1 seed, 2 tests, 1 source, 0 exposures, 1 metric, 401 macros, 0 groups, 1 semantic model
my_project.unique_my_model_v1_id
my_project.unique_my_model_v2_id

Note that there are 2 tests and they each have a unique node name.

In a group discussion yesterday about #9344, we considered what should happen if there is a single unit test with two versions.

We decided that it should behave similarly and output two nodes:

00:41:30  Found .. 2 unit tests ...
my_project.my_unit_test_my_model_v1
my_project.my_unit_test_my_model_v2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants