Vinai/elixir smoke test (#1815)

Elixir integration
This commit is contained in:
Vinai Rachakonda
2021-06-14 13:51:38 -04:00
committed by GitHub
parent e96009d96d
commit f494c8f478
4 changed files with 70 additions and 0 deletions

View File

@@ -86,6 +86,13 @@ WORKDIR /mysql-client-tests/ruby
RUN gem install bundler -v 2.1.4
RUN bundle install
# install elixir
RUN apt-get install wget
RUN wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb && dpkg -i erlang-solutions_2.0_all.deb
RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y esl-erlang
RUN apt-get install -y elixir
# install dolt from source
WORKDIR /root/building
COPY ./go .

View File

@@ -0,0 +1,33 @@
defmodule SmokeTest do
def myTestFunc(arg1, arg2) do
if arg1 != arg2 do
raise "Test error"
end
end
@spec run :: nil
def run do
args = System.argv()
user = Enum.at(args, 0)
{port, _} = Integer.parse(Enum.at(args, 1))
database = Enum.at(args, 2)
{:ok, pid} = MyXQL.start_link(username: user, port: port, database: database)
{:ok, _} = MyXQL.query(pid, "drop table if exists test")
{:ok, _} = MyXQL.query(pid, "create table test (pk int, `value` int, primary key(pk))")
{:ok, _} = MyXQL.query(pid, "describe test")
{:ok, result} = MyXQL.query(pid, "select * from test")
myTestFunc(result.num_rows, 0)
{:ok, _} = MyXQL.query(pid, "insert into test (pk, `value`) values (0,0)")
# MyXQL uses the CLIENT_FOUND_ROWS flag so we should return the number of rows matched
{:ok, result} = MyXQL.query(pid, "UPDATE test SET pk = pk where pk = 0")
myTestFunc(result.num_rows, 1)
{:ok, result} = MyXQL.query(pid, "SELECT * FROM test")
myTestFunc(result.num_rows, 1)
myTestFunc(result.rows, [[0,0]])
end
end

View File

@@ -0,0 +1,19 @@
defmodule Simple.MixProject do
use Mix.Project
def project do
[
app: :simple,
version: "0.1.0",
start_permanent: Mix.env() == :prod,
deps: deps()
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:myxql, "~> 0.5.0"},
]
end
end

View File

@@ -100,6 +100,17 @@ cmake ..
ruby $BATS_TEST_DIRNAME/ruby/ruby-mysql-test.rb $USER $PORT $REPO_NAME
}
@test "elixir myxql test" {
cd $BATS_TEST_DIRNAME/elixir/
# install some mix dependencies
mix local.hex --force
mix local.rebar --force
mix deps.get
# run the test
mix run -e "IO.puts(SmokeTest.run())" $USER $PORT $REPO_NAME
}
@test "mysqldump works" {
mysqldump $REPO_NAME -P $PORT -h 0.0.0.0 -u $USER
}