Skip to content

How to make "negative" unit tests? #2490

Discussion options

You must be logged in to vote

Hey @alessandro-gomma 👋 One approach is to write a test which expects 0 batches:

pipeline:
  processors:
    - mapping: |
        root = throw("kaboom!")
    - catch:
        - mapping: root = if errored() { deleted() }

tests:
  - name: test deleted
    target_processors: '/pipeline/processors'
    input_batch:
      - content: 'foobar'
    output_batches: []

Alternatively, depending on what your pipeline does and where you place that mapping processor which contains the deleted() call, you could mock it such that it returns some dummy data instead. Something like this:

pipeline:
  processors:
    - mapping: |
        root = throw("kaboom!")
    - catch:
        - label: mockme
          m…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by alessandro-gomma
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants