8000 mysql tests by woylie · Pull Request #568 · woylie/flop · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

mysql tests #568

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

Merged
merged 3 commits into from
May 28, 2025
Merged
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
8 changes: 7 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
services:
postgres:
image: postgres:12-alpine
image: postgres:17-alpine
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- "5432:5432"
mysql:
image: mysql:9.3
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: true
ports:
- "3306:3306"
4 changes: 3 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Flop.MixProject do

@source_url "https://github.com/woylie/flop"
@version "0.26.2"
@adapters ~w(postgres sqlite)
@adapters ~w(postgres sqlite mysql)

def project do
[
Expand Down Expand Up @@ -69,6 +69,7 @@ defmodule Flop.MixProject do
{:ex_machina, "== 2.8.0", only: :test},
{:makeup_diff, "== 0.1.1", only: :dev, runtime: false},
{:excoveralls, "== 0.18.5", only: :test},
{:myxql, "== 0.7.1", only: :test},
{:nimble_options, "~> 1.0"},
{:postgrex, "== 0.20.0", only: :test},
{:ecto_sqlite3, "== 0.19.0", only: :test},
Expand Down Expand Up @@ -119,6 +120,7 @@ defmodule Flop.MixProject do
defp aliases do
[
"test.all": ["test", "test.adapters"],
"test.mysql": &test_adapters(["mysql"], &1),
"test.postgres": &test_adapters(["postgres"], &1),
"test.sqlite": &test_adapters(["sqlite"], &1),
"test.adapters": &test_adapters/1,
Expand Down
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"makeup_diff": {:hex, :makeup_diff, "0.1.1", "01498f8c95970081297837eaf4686b6f3813e535795b8421f15ace17a59aea37", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "fadb0bf014bd328badb7be986eadbce1a29955dd51c27a9e401c3045cf24184e"},
"makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"},
"makeup_erlang": {:hex, :makeup_erlang, "1.0.2", "03e1804074b3aa64d5fad7aa64601ed0fb395337b982d9bcf04029d68d51b6a7", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "af33ff7ef368d5893e4a267933e7744e46ce3cf1f61e2dccf53a111ed3aa3727"},
"myxql": {:hex, :myxql, "0.7.1", "7c7b75aa82227cd2bc9b7fbd4de774fb19a1cdb309c219f411f82ca8860f8e01", [:mix], [{:db_connection, "~> 2.4.1 or ~> 2.5", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:geo, "~> 3.4", [hex: :geo, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "a491cdff53353a09b5850ac2d472816ebe19f76c30b0d36a43317a67c9004936"},
"nimble_options": {:hex, :nimble_options, "1.1.1", "e3a492d54d85fc3fd7c5baf411d9d2852922f66e69476317787a7b2bb000a61b", [:mix], [], "hexpm", "821b2470ca9442c4b6984882fe9bb0389371b8ddec4d45a9504f00a66f650b44"},
"nimble_parsec": {:hex, :nimble_parsec, "1.4.2", "8efba0122db06df95bfaa78f791344a89352ba04baedd3849593bfce4d0dc1c6", [:mix], [], "hexpm", "4b21398942dda052b403bbe1da991ccd03a053668d147d53fb8c4e0efe09c973"},
"postgrex": {:hex, :postgrex, "0.20.0", "363ed03ab4757f6bc47942eff7720640795eb557e1935951c1626f0d303a3aed", [:mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "d36ef8b36f323d29505314f704e21a1a038e2dc387c6409ee0cd24144e187c0f"},
Expand Down
1 change: 1 addition & 0 deletions test/adapters/ecto/mysql/all_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Code.require_file("../cases/flop_test.exs", __DIR__)
31 changes: 31 additions & 0 deletions test/adapters/ecto/mysql/migration.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
defmodule Flop.Repo.Mysql.Migration do
use Ecto.Migration

def change do
create table(:owners) do
add(:age, :integer)
add(:email, :string)
add(:name, :string)
add(:attributes, :map)
add(:extra, {:map, :string})
end

create table(:pets) do
add(:age, :integer)
add(:family_name, :string)
add(:given_name, :string)
add(:name, :string)
add(:owner_id, references(:owners))
add(:species, :string)
add(:mood, :string)
end

create table(:fruits) do
add(:family, :string)
add(:name, :string)
add(:attributes, :map)
add(:extra, {:map, :string})
add(:owner_id, references(:owners))
end
end
end
48 changes: 48 additions & 0 deletions test/adapters/ecto/mysql/test_helper.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Application.put_env(:flop, :async_integration_tests, true)

# Configure PG connection
Application.put_env(:flop, Flop.Repo,
username: "root",
password: "",
database: "flop_test#{System.get_env("MIX_TEST_PARTITION")}",
hostname: "localhost",
port: 3306,
pool: Ecto.Adapters.SQL.Sandbox
)

defmodule Flop.Repo do
use Ecto.Repo,
otp_app: :flop,
adapter: Ecto.Adapters.MyXQL
end

defmodule Flop.Integration.Case do
use ExUnit.CaseTemplate
alias Ecto.Adapters.SQL.Sandbox

setup do
:ok = Sandbox.checkout(Flop.Repo)
end

setup do
%{ecto_adapter: :mysql}
end
end

Code.require_file("migration.exs", __DIR__)

{:ok, _} =
Ecto.Adapters.MyXQL.ensure_all_started(Flop.Repo.config(), :temporary)

# Load up the repository, start it, and run migrations
Ecto.Adapters.MyXQL.storage_down(Flop.Repo.config())
Ecto.Adapters.MyXQL.storage_up(Flop.Repo.config())

{:ok, _pid} = Flop.Repo.start_link()

Ecto.Migrator.up(Flop.Repo, 0, Flop.Repo.Mysql.Migration, log: true)

Ecto.Adapters.SQL.Sandbox.mode(Flop.Repo, :manual)

{:ok, _} = Application.ensure_all_started(:ex_machina)
ExUnit.start(exclude: [:prefix])
0