Ash FrameworkAF
Ash Framework3mo ago
3 replies
⿻ eileen

Testing Filters

I'm writing a function that dynamically adds filters to an Ash.Query for AshBackpex. I'm not sure how to assert that I'm getting the filters back that I want.

I can't figure out how to assert against this structure:

#Ash.Query<
  resource: AshBackpex.TestDomain.Post,
  action: :read,
  filter: #Ash.Filter<contains(title, "foo bar")>
>


I can do this:

  result = MyMod.my_func(query, ...) 
  dbg(result.filter.expression)


And I get: contains(title, "foo bar")

But I don't know how to pattern match or make assertions against that.

I can also use Ash.Filter.to_simple_filter(...) and assert against the length filter.predicates , which might actually be enough for this use case. But I'd like to get more specific if possible.
Was this page helpful?