bento icon indicating copy to clipboard operation
bento copied to clipboard

bloblang import does not work in unittest

Open henrikschristensen opened this issue 2 months ago • 1 comments

Running Unit tests for a pipeline with import ".blobl file" fails with: failed to read import: open /home/nixos/repo/OpenIntegration/src/streams/fxmanager/maps/quoterequest.blobl: no such file or directory: impor

This works fine when running the pipeline.


pipeline:
  processors:
    - try:
       - branch:
          request_map: |
            import "./src/streams/fxmanager/maps/quoterequest.blobl"
            root = this.request.apply("secondary_currency")
          processors:
            - log:
                level: INFO
                message: "hello world"
          result_map: |
            root = this

tests:
  - name: Failing
    input_batch:
      - content: |
          {
          }
    output_batches:
      - - json_equals: |
            {
            }

henrikschristensen avatar Oct 30 '25 14:10 henrikschristensen

Hey @henrikschristensen 👋 Have you tried using the target_mapping parameter as a workaround?

See docs for unit testing bloblang

I haven't confirmed this, but I'm assuming that bloblang environment for unit testing is likely sandboxed -- preventing you from directly reading envars and files from the host OS.

Let me know if this solves the issue!

gregfurman avatar Nov 09 '25 12:11 gregfurman

@henrikschristensen can we close this or are you stille experiencing issues?

gregfurman avatar Dec 01 '25 09:12 gregfurman