This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the info endpoint by serializing the
Info
struct (#28)
* Fix the info endpoint by serializing the `Info` struct Makes sure all structs are properly serialized in order to be returned as json. In addition, adds a test to verify the info endpoint works and fixes a couple of issues when inserting keysets in the database. * test * format --------- Co-authored-by: Andres Ruiz <[email protected]>
- Loading branch information
Showing
7 changed files
with
51 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ defmodule Cashubrew.Nuts.Nut02.Keyset do | |
end | ||
|
||
defp keyset_id_version do | ||
<<0>> | ||
"00" | ||
end | ||
|
||
@doc """ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
defmodule Cashubrew.Nuts.Nut06Test do | ||
use Cashubrew.Test.ConnCase | ||
|
||
test "info", %{conn: conn} do | ||
conn = get(conn, ~p"/api/v1/info") | ||
data = json_response(conn, 200) | ||
|
||
assert Map.has_key?(data, "contact") | ||
assert Map.has_key?(data, "nuts") | ||
assert Map.has_key?(data, "pubkey") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
defmodule Cashubrew.Test.ConnCase do | ||
@moduledoc """ | ||
This module defines helpers to be used by tests that require an http connection. | ||
It also starts a sandboxed database connection. | ||
""" | ||
use ExUnit.CaseTemplate | ||
|
||
using do | ||
quote do | ||
@endpoint Cashubrew.Web.Endpoint | ||
|
||
use Cashubrew.Web, :verified_routes | ||
|
||
import Plug.Conn | ||
import Phoenix.ConnTest | ||
import Cashubrew.Test.ConnCase | ||
end | ||
end | ||
|
||
setup tags do | ||
Cashubrew.Test.ConnCase.setup_sandbox(tags) | ||
{:ok, conn: Phoenix.ConnTest.build_conn()} | ||
end | ||
|
||
def setup_sandbox(tags) do | ||
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(Cashubrew.Repo, shared: not tags[:async]) | ||
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end) | ||
end | ||
end |