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-3110] [Implementation] Support a configurable format: csv attribute on a given input and expect fixtures in unit tests #8626

Closed
Tracked by #8283
MichelleArk opened this issue Sep 12, 2023 · 1 comment · Fixed by #8743
Assignees

Comments

@MichelleArk
Copy link
Contributor

MichelleArk commented Sep 12, 2023

Acceptance Criteria:

  • extend the existing unit test spec to support format: csv
    • by default, the format should be dict
  • support supplying inline csv strings when format is csv
unit:
  - model: my_model
    tests:
      - name: test_my_model
        given:
          - input: ref('my_model_a')
            format: csv
            rows: |
            c
            3
          - input: ref('my_model_b')
            format: csv
            rows: |
            id, b
            1,  2
            2, 2
        expect:
          format: csv
          rows: |
          c
          3

Technical Considerations:

  • this will need updates in both the InputFixture and given schemas. Currently they are different objects/types but we should consider unifying them to both inheriting from a Fixture class in order to share logic/structure for configurable formats.

Question: should the default format be overridable? Perhaps at the project-level? It could be annoying to always have to specify format: csv in every given and expect configuration when the project has a general preference for csv over dict @graciegoheen. Perhaps a top-level fixtures config in dbt_project.yml?

@github-actions github-actions bot changed the title [Implementation] Support a configurable format: csv attribute on a given input and expect fixtures in unit tests [CT-3110] [Implementation] Support a configurable format: csv attribute on a given input and expect fixtures in unit tests Sep 12, 2023
@graciegoheen
Copy link
Contributor

graciegoheen commented Sep 18, 2023

It could be annoying to always have to specify format: csv in every given and expect configuration when the project has a general preference for csv over dict @graciegoheen. Perhaps a top-level fixtures config in dbt_project.yml?

@MichelleArk Yep, I think you're instinct is correct here. We should allow folks to override the default for the format config at the project level (similar to how we allow setting the severity config for data tests). What if this just went under unit-tests: in the dbt_project.yml?

unit-tests:
  +format: csv  # all unit tests

We can also open a new issue for this enhancement if this feels out of scope for the current ticket or needs more product / dx refinement.

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.

3 participants