Skip to content

Commit 32199aa

Browse files
authored
Merge pull request #257 from cipherstash/feature/elixir-integration-test
Feature/elixir integration test
2 parents 1044326 + df276d0 commit 32199aa

File tree

15 files changed

+383
-4
lines changed

15 files changed

+383
-4
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Used by "mix format"
2+
[
3+
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
4+
]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# The directory Mix will write compiled artifacts to.
2+
/_build/
3+
4+
# If you run "mix test --cover", coverage assets end up here.
5+
/cover/
6+
7+
# The directory Mix downloads your dependencies sources to.
8+
/deps/
9+
10+
# Where third-party dependencies like ExDoc output generated docs.
11+
/doc/
12+
13+
# Ignore .fetch files in case you like to edit your project deps locally.
14+
/.fetch
15+
16+
# If the VM crashes, it generates a dump, let's ignore it too.
17+
erl_crash.dump
18+
19+
# Also ignore archive artifacts (built via "mix archive.build").
20+
*.ez
21+
22+
# Ignore package tarball (built via "mix hex.build").
23+
elixir_test-*.tar
24+
25+
# Temporary files, for example, from tests.
26+
/tmp/
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# ElixirTest
2+
3+
This directory contains the test project which uses ecto to run some integration tests.
4+
5+
## Running
6+
7+
The tests can be run using [mise](https://mise.jdx.dev/).
8+
9+
From the project root directory, run:
10+
```
11+
test:integration:lang:elixir
12+
```
13+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Config
2+
3+
config :elixir_test, ElixirTest.Repo,
4+
database: "cipherstash",
5+
username: "cipherstash",
6+
port: 6432,
7+
password: "p@ssword",
8+
hostname: "proxy",
9+
pool: Ecto.Adapters.SQL.Sandbox
10+
11+
config :elixir_test, ecto_repos: [ElixirTest.Repo]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
defmodule ElixirTest do
2+
@moduledoc """
3+
Top level module for `ElixirTest`.
4+
"""
5+
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
defmodule ElixirTest.Application do
2+
def start(_type, _args) do
3+
children = [
4+
ElixirTest.Repo
5+
]
6+
7+
opts = [strategy: :one_for_one, name: ElixirTest.Supervisor]
8+
9+
Supervisor.start_link(children, opts)
10+
end
11+
end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
defmodule ElixirTest.Encrypted do
2+
use Ecto.Schema
3+
import Ecto.Changeset
4+
5+
@primary_key {:id, :id, autogenerate: false}
6+
schema "encrypted" do
7+
field(:plaintext, :string)
8+
field(:plaintext_date, :date)
9+
field(:encrypted_text, :string)
10+
field(:encrypted_bool, :boolean)
11+
field(:encrypted_int2, :integer)
12+
field(:encrypted_int4, :integer)
13+
field(:encrypted_int8, :integer)
14+
field(:encrypted_float8, :float)
15+
field(:encrypted_date, :date)
16+
field(:encrypted_jsonb, :map)
17+
end
18+
19+
def changeset(encrypted, attrs) do
20+
encrypted
21+
|> cast(attrs, [
22+
:id,
23+
:plaintext,
24+
:plaintext_date,
25+
:encrypted_text,
26+
:encrypted_bool,
27+
:encrypted_int2,
28+
:encrypted_int4,
29+
:encrypted_int8,
30+
:encrypted_float8,
31+
:encrypted_date,
32+
:encrypted_jsonb
33+
])
34+
end
35+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
defmodule ElixirTest.Repo do
2+
use Ecto.Repo,
3+
otp_app: :elixir_test,
4+
adapter: Ecto.Adapters.Postgres
5+
end
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
defmodule ElixirTest.MixProject do
2+
use Mix.Project
3+
4+
def project do
5+
[
6+
app: :elixir_test,
7+
version: "0.1.0",
8+
elixir: "~> 1.16",
9+
start_permanent: Mix.env() == :prod,
10+
deps: deps()
11+
]
12+
end
13+
14+
# Run "mix help compile.app" to learn about applications.
15+
def application do
16+
[
17+
extra_applications: [:logger],
18+
mod: {ElixirTest.Application, []}
19+
]
20+
end
21+
22+
# Run "mix help deps" to learn about dependencies.
23+
defp deps do
24+
[
25+
{:ecto_sql, "~> 3.12"},
26+
{:postgrex, "~> 0.20"},
27+
{:jason, "~> 1.4"}
28+
]
29+
end
30+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
%{
2+
"db_connection": {:hex, :db_connection, "2.7.0", "b99faa9291bb09892c7da373bb82cba59aefa9b36300f6145c5f201c7adf48ec", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "dcf08f31b2701f857dfc787fbad78223d61a32204f217f15e881dd93e4bdd3ff"},
3+
"decimal": {:hex, :decimal, "2.3.0", "3ad6255aa77b4a3c4f818171b12d237500e63525c2fd056699967a3e7ea20f62", [:mix], [], "hexpm", "a4d66355cb29cb47c3cf30e71329e58361cfcb37c34235ef3bf1d7bf3773aeac"},
4+
"ecto": {:hex, :ecto, "3.12.5", "4a312960ce612e17337e7cefcf9be45b95a3be6b36b6f94dfb3d8c361d631866", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "6eb18e80bef8bb57e17f5a7f068a1719fbda384d40fc37acb8eb8aeca493b6ea"},
5+
"ecto_sql": {:hex, :ecto_sql, "3.12.1", "c0d0d60e85d9ff4631f12bafa454bc392ce8b9ec83531a412c12a0d415a3a4d0", [:mix], [{:db_connection, "~> 2.4.1 or ~> 2.5", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.12", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.7", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.19 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "aff5b958a899762c5f09028c847569f7dfb9cc9d63bdb8133bff8a5546de6bf5"},
6+
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
7+
"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"},
8+
"telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"},
9+
}

0 commit comments

Comments
 (0)