简体   繁体   English

测试期间如何运行真实的phoenix服务器?

[英]How to run real phoenix server during test?

I'm implementing kinda tricky functionality with external libraries I can't mock. 我正在使用无法模拟的外部库实现某种棘手的功能。 They needs to implement real requests to the server. 他们需要对服务器实施真正的请求。 So, 所以,

how can I run a web-server during tests implementation? 在测试实施过程中如何运行Web服务器?

PS My config/test.exs : PS我的config/test.exs

config :my_reelty, MyReelty.Endpoint,
  http: [port: {:system, "PORT"}],
  url:  [host: "localhost", port: 5000] # Specific port

I'm trying to curl http://localhost:5000 but getting curl: (7) Failed to connect to localhost port 5000: Connection refused 我正在尝试curl http://localhost:5000但变得curl: (7) Failed to connect to localhost port 5000: Connection refused

You need to add server: true to the Endpoint 's config: 您需要将server: true添加到Endpoint的配置中:

config :my_reelty, MyReelty.Endpoint, server: true

The phoenix.new may have already generated similar config with server: false (it does for me in v1.2.0), so you can just change that false to true . phoenix.new可能已经使用server: false生成了类似的配置(在v1.2.0中对我有用),因此您可以将false更改为true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM