Skip to content

Commit a1d08a7

Browse files
committed
Remove Faker dependency
Faker was only used for generating random strings. We are generating the random strings ourselves so we can remove the Faker dependency.
1 parent b0531c0 commit a1d08a7

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

mix.exs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ defmodule Trans.Mixfile do
5050
{:ecto_sql, "~> 3.0", optional: true},
5151
{:postgrex, "~> 0.14", optional: true},
5252
# Doc dependencies
53-
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
54-
# Test dependencies
55-
{:faker, "~> 0.7.0", only: :test}
53+
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false}
5654
]
5755
end
5856

mix.lock

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66
"ecto": {:hex, :ecto, "3.0.4", "5d0e2b89baaa03eac37ec49f9018c39a4e2fb6501dc3ff5a839de742e171a09f", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"},
77
"ecto_sql": {:hex, :ecto_sql, "3.0.3", "dd17f2401a69bb2ec91d5564bd259ad0bc63ee32c2cb2e616d04f1559801dba6", [:mix], [{:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.0.4", [hex: :ecto, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.9.1", [hex: :mariaex, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.14.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.2.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"},
88
"ex_doc": {:hex, :ex_doc, "0.21.3", "857ec876b35a587c5d9148a2512e952e24c24345552259464b98bfbb883c7b42", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
9-
"faker": {:hex, :faker, "0.7.0", "2c42deeac7be717173c78c77fb3edc749fb5d5e460e33d01fe592ae99acc2f0d", [:mix], [], "hexpm"},
109
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
1110
"makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
1211
"makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"},
1312
"nimble_parsec": {:hex, :nimble_parsec, "0.5.3", "def21c10a9ed70ce22754fdeea0810dafd53c2db3219a0cd54cf5526377af1c6", [:mix], [], "hexpm"},
14-
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"},
15-
"poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], [], "hexpm"},
1613
"postgrex": {:hex, :postgrex, "0.14.1", "63247d4a5ad6b9de57a0bac5d807e1c32d41e39c04b8a4156a26c63bcd8a2e49", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"},
1714
"telemetry": {:hex, :telemetry, "0.2.0", "5b40caa3efe4deb30fb12d7cd8ed4f556f6d6bd15c374c2366772161311ce377", [:mix], [], "hexpm"},
1815
}

test/support/factory.ex

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,40 @@ defmodule Trans.Factory do
1515

1616
def build(:article) do
1717
%Article{
18-
title: Faker.Lorem.sentence(5, " "),
19-
body: Faker.Lorem.sentence(10, " "),
18+
title: unique_string("Article title in English"),
19+
body: unique_string("Article body in English"),
2020
comments: [build(:comment), build(:comment)],
2121
translations: %{
2222
"es" => %{
23-
"title" => Faker.Lorem.sentence(5, " "),
24-
"body" => Faker.Lorem.sentence(10, " ")
23+
"title" => unique_string("Article title in Spanish"),
24+
"body" => unique_string("Article body in Spanish")
2525
},
2626
"fr" => %{
27-
"title" => Faker.Lorem.sentence(5, " "),
28-
"body" => Faker.Lorem.sentence(10, " ")
27+
"title" => unique_string("Article title in French"),
28+
"body" => unique_string("Article body in French")
2929
}
3030
}
3131
}
3232
end
3333

3434
def build(:comment) do
3535
%Comment{
36-
comment: Faker.Lorem.sentence(5, " "),
36+
comment: unique_string("Comment in English"),
3737
transcriptions: %{
38-
"es" => %{"comment" => Faker.Lorem.sentence(5, " ")},
39-
"fr" => %{"comment" => Faker.Lorem.sentence(5, " ")}
38+
"es" => %{"comment" => unique_string("Comment in Spanish")},
39+
"fr" => %{"comment" => unique_string("Comment in French")}
4040
}
4141
}
4242
end
43+
44+
# Adds a random suffix to the given string to make it unique.
45+
defp unique_string(string) do
46+
suffix =
47+
string
48+
|> String.length()
49+
|> :crypto.strong_rand_bytes()
50+
|> Base.url_encode64()
51+
52+
Enum.join([string, suffix], " - ")
53+
end
4354
end

0 commit comments

Comments
 (0)