Comments (1)
Update:
I think I made big step with this case. I digged into issues here and I found something that looks promising to me. After all it still shows an error but I think it's pretty easy to pass, but still I didnt found solution.
I added to test folder Ets Cache Mock:
defmodule PowApiTemplate.Test.EtsCacheMock do
@moduledoc false
@tab __MODULE__
def init, do: :ets.new(@tab, [:ordered_set, :protected, :named_table])
def get(config, key) do
ets_key = ets_key(config, key)
@tab
|> :ets.lookup(ets_key)
|> case do
[{^ets_key, value} | _rest] -> value
[] -> :not_found
end
end
def delete(config, key) do
:ets.delete(@tab, ets_key(config, key))
:ok
end
def put(config, record_or_records) do
records = List.wrap(record_or_records)
ets_records = Enum.map(records, fn {key, value} ->
{ets_key(config, key), value}
end)
send(self(), {:ets, :put, records, config})
:ets.insert(@tab, ets_records)
end
def all(config, match) do
ets_key_match = ets_key(config, match)
@tab
|> :ets.select([{{ets_key_match, :_}, [], [:"$_"]}])
|> Enum.map(fn {[_namespace | keys], value} -> {keys, value} end)
end
defp ets_key(config, key) do
[Keyword.get(config, :namespace, "cache")] ++ List.wrap(key)
end
end
Updated test config with:
config :pow_api_template, :pow,
cache_backend: [cache_store_backend: PowApiTemplate.Test.EtsCacheMock]
Error is the same if I change it to:
config :pow_api_template, :pow,
cache_store_backend: PowApiTemplate.Test.EtsCacheMock
I updated conn_case.ex with:
setup _tags do
EtsCacheMock.init()
{:ok, conn: Phoenix.ConnTest.build_conn(), ets: EtsCacheMock}
end
Adding this line to test_helper.exs leads to fail all tests - even with registration/session controllers:
PowApiTemplate.Test.EtsCacheMock.init()
I also updated password_controller_test.exs:
setup do
user =
%User{}
|> User.changeset(%{email: "[email protected]", password: @password, password_confirmation: @password})
|> Repo.insert!()
{:ok, user: user}
end
describe "reset_password/2" do
test "with valid token and passwords", %{conn: conn} do
PowApiTemplate.Test.EtsCacheMock.init()
pow_config = [otp_app: :pow_api_template]
{:ok, %{token: token, user: user}, conn} =
conn
|> Pow.Plug.put_config(Application.get_env(:pow_api_template, :pow))
|> PowResetPassword.Plug.create_reset_token(%{"email" => "[email protected]"})
valid_params = %{"id" => token, "user" => %{"password" => @new_password, "password_confirmation" => @new_password}}
conn = post(conn, Routes.password_path(conn, :reset_password, valid_params))
assert json = json_response(conn, 200)
end
end
Trying to start test leads to error:
1) test reset_password/2 with valid token and passwords (PowApiTemplateWeb.PasswordControllerTest)
test/pow_api_template_web/controllers/password_controller_test.exs:45
** (ArgumentError) errors were found at the given arguments:
* 2nd argument: invalid options
code: PowApiTemplate.Test.EtsCacheMock.init()
stacktrace:
(stdlib 4.0.1) :ets.new(PowApiTemplate.Test.EtsCacheMock, [:set, :protected, :named_table])
(pow_api_template 0.1.0) test/support/ets_cache_mock.ex:5: PowApiTemplate.Test.EtsCacheMock.init/0
test/pow_api_template_web/controllers/password_controller_test.exs:46: (test)
I also changed :set to :ordered_set but nothing changes with error. Maybe in Pow 1.0.27 there are changes that I didnt implemented or I wrote something incorrectly. I'll check later PowApiTemplate.Test.EtsCacheMock.init() function and I will try to play with options.
from pow.
Related Issues (20)
- Auto-joining Nodes with Mnesia Backend HOT 20
- I'm getting "no :user configuration option found"
- Are there fixtures? contexts?
- Test from API document is failing HOT 4
- Issue related to `Pow.Store.Backend.MnesiaCache` HOT 1
- Various ways of signing in a user? (ie., via email, phone_number, username) HOT 6
- Official documentation on how to use Pow with LiveView HOT 7
- ecto_sql 3.8.0 gives compilation error for generated user schema HOT 4
- Replacing Phoenix.Token with JWT-based for signing and verifiying of tokens HOT 1
- Unable to logout user in Pow API HOT 2
- Feature Request: Apple Passkeys HOT 1
- Pow.Plug.authenticate_user/1 performance HOT 2
- Upgrading to Phoenix 1.7 HOT 5
- Create account without email/password using some unique ID?
- Phoenix 1.7 compilers warning HOT 1
- Maintain case when storing emails HOT 2
- Permissions issues with mnesia backend for Pow HOT 15
- Improve mix tasks
- Crash @missing_field? in Schema.ex HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pow.