Using functions in dbt unit_tests

The problem I’m having

I’m trying to build a unit test verifying our email address validation using an existing model. This model has a clause that only looks back at the last 365 days of data for the select. As such, at mininum, I have to supply the email and a timestamp field.

I could technically supply a fixed timestamp, but it would feel hacky as technically in a year the test would simply start to fail.

The context of why I’m trying to do this

unit test two macro functions that are used by that model in particular, one being an email clean up macro and the other an email validation one.

What I’ve already tried

I tried the ai bot assistant and it gave answers that looked like they could work, but none of them did:

  • using the sql format. It technically works, but it’s not scalable at all, considering the model in question has about 40 or so columns and I don’t want to define them all manually.
  • use jinja wrappers: "{{ current_timestamp() }} and “{{ dbt_utils.current_timestamp() }}”
  • override dbt_utils.current timestamp with overrides: macros: dbt_utils.current_timestamp: "current_timestamp()" but it didn’t work or made sense really.

Some example code or error messages

given:
  - input: ref('source_table')
    rows:
      - {email: 'test@mail.com', timestamp: current_timestamp()}
      - {email: 'test @mail.com', timestamp: current_timestamp()}

Right now, what it compiles to is this, which is taken as a string and not compiled into the current timestamp value:
TRY_CAST('current_timestamp()' AS TIMESTAMP_NTZ) as timestamp