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-3291] [Feature] unit test models that depend on external nodes #8944

Closed
3 tasks done
Tracked by #8283
graciegoheen opened this issue Oct 30, 2023 · 2 comments · Fixed by #9343
Closed
3 tasks done
Tracked by #8283

[CT-3291] [Feature] unit test models that depend on external nodes #8944

graciegoheen opened this issue Oct 30, 2023 · 2 comments · Fixed by #9343
Assignees
Labels
enhancement New feature or request

Comments

@graciegoheen
Copy link
Contributor

graciegoheen commented Oct 30, 2023

Is this your first time submitting a feature request?

  • I have read the expectations for open source contributors
  • I have searched the existing issues, and I could not find an existing issue for this feature
  • I am requesting a straightforward extension of existing dbt functionality, rather than a Big Idea better suited to a discussion

Describe the feature

You should be able to unit test models that depend on external nodes!

unit_tests:
  - name: test_is_valid_email_address # this is the unique name of the test
    model: my_model # name of the model I'm unit testing
    given: 
      - input: ref('dougs_project', 'users')
        rows:
         - {user_id: 1, email: cool@example.com,     email_top_level_domain: example.com}
         - {user_id: 2, email: cool@unknown.com,     email_top_level_domain: unknown.com}
         - {user_id: 3, email: badgmail.com,         email_top_level_domain: gmail.com}
         - {user_id: 4, email: missingdot@gmailcom,  email_top_level_domain: gmail.com}
      - input: ref('top_level_domains')
        rows:
         - {tld: example.com}
         - {tld: gmail.com}
    expect: # required: the expected output given the inputs above
      - {user_id: 1, is_valid_email_address: true}
      - {user_id: 2, is_valid_email_address: false}
      - {user_id: 3, is_valid_email_address: false}
      - {user_id: 4, is_valid_email_address: false}

Describe alternatives you've considered

No response

Who will this benefit?

No response

Are you interested in contributing this feature?

No response

Anything else?

No response

@graciegoheen graciegoheen added the enhancement New feature or request label Oct 30, 2023
@github-actions github-actions bot changed the title [Feature] unit test models that depend on cross-project refs [CT-3291] [Feature] unit test models that depend on cross-project refs Oct 30, 2023
@MichelleArk MichelleArk changed the title [CT-3291] [Feature] unit test models that depend on cross-project refs [CT-3291] [Feature] unit test models that depend on external nodes Nov 13, 2023
@MichelleArk
Copy link
Contributor

This could be tested similar to what's done for testing partial parsing with external nodes here

@graciegoheen
Copy link
Contributor Author

Notes from estimation:

  • This may already work, but we should add a test and add more defense code for how we're handling these node attributes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants