Coder Social home page Coder Social logo

Comments (4)

phortx avatar phortx commented on August 30, 2024

I'm not sure wether I fully understand how the sandbox is actually working, but seems like the issue here is that the request is handled by the LemonEx Plug outside of the phoenix routing and thus the sandbox is not correct setup. I've played around with several code snippets from the documentation for enabling the Ecto Sandbox for LiveView, but couldn't produce a working solution 🤔

from wallaby.

mhanberg avatar mhanberg commented on August 30, 2024

Basically you'll want to add the relevant metadata to the useragent string in your request (you can use the functions in this module to create them https://hexdocs.pm/phoenix_ecto/4.6.1/Phoenix.Ecto.SQL.Sandbox.html) and make sure that it goes through the sandbox plug that is in your endpoint

from wallaby.

mhanberg avatar mhanberg commented on August 30, 2024

To clarify (because the docs I listed show how to set it up for "external clients"), the wallaby test has already checked out a db connection for your test, and ensured that the LV/controller process uses that connection.

The problem is that your webhook request controller doesn't know what db connection to checkout, but that is what the user agent meta string will tell the sandbox plug what to do

from wallaby.

phortx avatar phortx commented on August 30, 2024

To clarify (because the docs I listed show how to set it up for "external clients"), the wallaby test has already checked out a db connection for your test, and ensured that the LV/controller process uses that connection.

You're right, that's what I figured out too.

I think I solved the issue by adding:

metadata =
      MyApp.Repo
      |> Phoenix.Ecto.SQL.Sandbox.metadata_for(self())
      |> Phoenix.Ecto.SQL.Sandbox.encode_metadata()

and then passing this as user-agent header to the api request. Seems to work :)

Thank you very much for your help!

from wallaby.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.