Skip to content

Fix crash on error detail page when using MariaDB #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
mysql:
image: mysql:9
ports: ["3307:3306"]
env:
MYSQL_ROOT_PASSWORD: root
options: >-
--health-cmd "mysqladmin ping --password=root"
--health-interval 10s
--health-timeout 5s
--health-retries 5
name: Elixir v${{ matrix.elixir }}, Erlang v${{ matrix.erlang }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -96,7 +106,12 @@ jobs:
env:
DB: postgres

- name: Run Tests - MySQL/MariaDB
- name: Run Tests - MariaDB
run: mix test
env:
DB: mariadb

- name: Run Tests - MySQL
run: mix test
env:
DB: mysql
DB: mysql
9 changes: 8 additions & 1 deletion config/test.example.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ config :error_tracker, ErrorTracker.Test.Repo,
pool: Ecto.Adapters.SQL.Sandbox,
log: false

config :error_tracker, ErrorTracker.Test.MariaDBRepo,
url: "ecto://root:[email protected]:3306/error_tracker_test",
pool: Ecto.Adapters.SQL.Sandbox,
log: false,
# Use the same migrations as the PostgreSQL repo
priv: "priv/repo"

config :error_tracker, ErrorTracker.Test.MySQLRepo,
url: "ecto://root:[email protected]/error_tracker_test",
url: "ecto://root:[email protected]:3307/error_tracker_test",
pool: Ecto.Adapters.SQL.Sandbox,
log: false,
# Use the same migrations as the PostgreSQL repo
Expand Down
15 changes: 15 additions & 0 deletions test/error_tracker/store_fetch_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
defmodule ErrorTracker.StoreFetchTest do
@moduledoc """
Test if simple store-retrieve operations are successful.

This is necessary, because some Ecto adapters like `Ecto.Adapters.MyXQL` may successfully store a field, but crash on retrieval.
"""
use ErrorTracker.Test.Case

test "after reporting an error its occurrence should be retrievable from DB" do

Check failure on line 9 in test/error_tracker/store_fetch_test.exs

View workflow job for this annotation

GitHub Actions / Elixir v1.17.x, Erlang v27.x

test after reporting an error its occurrence should be retrievable from DB (ErrorTracker.StoreFetchTest)

Check failure on line 9 in test/error_tracker/store_fetch_test.exs

View workflow job for this annotation

GitHub Actions / Elixir v1.18.x, Erlang v27.x

test after reporting an error its occurrence should be retrievable from DB (ErrorTracker.StoreFetchTest)

Check failure on line 9 in test/error_tracker/store_fetch_test.exs

View workflow job for this annotation

GitHub Actions / Elixir v1.15.x, Erlang v24.x

test after reporting an error its occurrence should be retrievable from DB (ErrorTracker.StoreFetchTest)

Check failure on line 9 in test/error_tracker/store_fetch_test.exs

View workflow job for this annotation

GitHub Actions / Elixir v1.16.x, Erlang v24.x

test after reporting an error its occurrence should be retrievable from DB (ErrorTracker.StoreFetchTest)
assert %ErrorTracker.Occurrence{id: occurrence_id} =
report_error(fn -> raise "BOOM" end)

assert %ErrorTracker.Occurrence{} = repo().get!(ErrorTracker.Occurrence, occurrence_id)
end
end
4 changes: 4 additions & 0 deletions test/support/mariadb_repo.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
defmodule ErrorTracker.Test.MariaDBRepo do
@moduledoc false
use Ecto.Repo, otp_app: :error_tracker, adapter: Ecto.Adapters.MyXQL
end
5 changes: 4 additions & 1 deletion test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ repo =
"mysql" ->
ErrorTracker.Test.MySQLRepo

"mariadb" ->
ErrorTracker.Test.MariaDBRepo

"postgres" ->
ErrorTracker.Test.Repo

_other ->
raise "Please run either `DB=sqlite mix test`, `DB=postgres mix test` or `DB=mysql mix test`"
raise "Please run either `DB=sqlite mix test`, `DB=postgres mix test`, `DB=mariadb mix test` or `DB=mysql mix test`"
end

Application.put_env(:error_tracker, :repo, repo)
Expand Down
Loading