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-3437] add test coverage for unit testing a model that depends on a snapshot #9179

Closed
1 task done
Tracked by #8283
graciegoheen opened this issue Nov 29, 2023 · 0 comments · Fixed by #9592
Closed
1 task done
Tracked by #8283
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@graciegoheen
Copy link
Contributor

Housekeeping

  • I am a maintainer of dbt-core

Short description

You should be able to unit test models that depend on snapshots! Many projects snapshot sources and build int/fct/dim tables off those.

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('snapshot_users') # a snapshot
        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}

Acceptance criteria

  • add a test for unit testing a model that depends on a snapshot

Impact to Other Teams

none

Will backports be required?

none

Context

No response

@graciegoheen graciegoheen added the user docs [docs.getdbt.com] Needs better documentation label Nov 29, 2023
@github-actions github-actions bot changed the title add test coverage for unit testing a model that depends on a snapshot [CT-3437] add test coverage for unit testing a model that depends on a snapshot Nov 29, 2023
@graciegoheen graciegoheen added enhancement New feature or request and removed user docs [docs.getdbt.com] Needs better documentation labels Nov 29, 2023
@martynydbt martynydbt added this to the v1.8 milestone Feb 12, 2024
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
Development

Successfully merging a pull request may close this issue.

3 participants