I am writing test cases for a library which makes dynamic queries for where, joins, select easy.
I have created models which don’t persist in the database and test these functions.
Each of these functions return the query,
I am testing these functions to see if they build up a correct query not the ecto
This is the code:
test "returns the query where field like" do
opts = %{
"$where" => %{"first_name" => %{"$like" => "%Ham %"}}
}
expected = from w in TestModel.Where, where: like(w.first_name, ^"%Ham %")
assert build(TestModel.Where, opts) == expected
end
expected is the query which it returned in the console.
This is what i get in return when I try to run the tests and it failed.
left side of assert is pointed to the function file and right side to the test file
Any suggestions or idea about better approach.
Thanks























