vendredi 17 juillet 2020

Elixir Postgres view returning empty dataset when testing

I am trying to test a view created in Postgres, but it is returning an empty result set. However, when testing out the view in an Elixir interactive shell, I get back the expected data. Here are the steps I have taken to create and test the view:

  1. Create a migration:
 def up do
   execute """
     CREATE VIEW example_view AS
     ...
  1. Create the schema:
  import Ecto.Changeset

  schema "test_view" do
   field(:user_id, :string)
  1. Test:
  describe "example loads" do
   setup [
     :with_example_data
   ]

   test "view" do
     query = from(ev in Schema.ExampleView)
     IO.inspect Repo.all(query)
   end
 end

The response back is an empty array []

Is there a setting that I am missing to allow for views to be tested in test?

Aucun commentaire:

Enregistrer un commentaire