Skip to content
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

Make tests compatible with Elixir 1.16 and 1.17 #565

Open
wants to merge 75 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
1a96fa6
Use :rand.uniform for random_between
ypconstante Jun 16, 2024
a692be3
Update tests
ypconstante Jun 16, 2024
9fb79f4
Use random_betwen for random_bytes
ypconstante Jun 16, 2024
b0854cb
Use random_uniform to shuffle data
ypconstante Jun 16, 2024
004f7bf
Add Elixir 1.16 and Elixir 1.17 to CI
ypconstante Jun 16, 2024
e76e2ea
Update changelog
ypconstante Jun 16, 2024
1cef1b8
Test only with OTP 25
ypconstante Jun 16, 2024
302d9d5
Fix tests on OTP 26
ypconstante Jun 16, 2024
3bb5251
Add OTP 26 and 27 on CI
ypconstante Jun 16, 2024
7a778c1
Update changelog
ypconstante Jun 16, 2024
28e6c46
fix: CI matrix
igas Jun 26, 2024
df4c5b9
fix(ci): upgrade to 24.04 ubuntu
igas Jun 26, 2024
a5b360b
fix: drop pre breaking change in elixir
igas Aug 20, 2024
96bdeb0
fix: drop unnecessary change
igas Aug 20, 2024
383c280
fix: accidental future api slip
igas Aug 20, 2024
e073df5
fix: missing import
igas Aug 20, 2024
604cde0
fix: ci
igas Aug 20, 2024
672b646
fix: missing md import
igas Aug 20, 2024
f88b6a7
fix: address tests
igas Aug 23, 2024
6b135df
fix: more tests
igas Aug 24, 2024
69c313e
fix(ci): check
igas Sep 10, 2024
3d21824
Discard changes to lib/faker/address.ex
igas Sep 10, 2024
ef008e5
Discard changes to lib/faker/address/en.ex
igas Sep 10, 2024
20b65f8
Discard changes to lib/faker/address/es.ex
igas Sep 10, 2024
d2ecd08
Discard changes to lib/faker/address/hy.ex
igas Sep 10, 2024
71cd962
Discard changes to lib/faker/address/it.ex
igas Sep 10, 2024
c3464de
Discard changes to lib/faker/address/pt_br.ex
igas Sep 10, 2024
445a39a
Discard changes to lib/faker/address/ru.ex
igas Sep 10, 2024
a482227
Discard changes to lib/faker/airports.ex
igas Sep 10, 2024
d9e4af5
Discard changes to lib/faker/airports/en.ex
igas Sep 10, 2024
df44be9
Discard changes to lib/faker/airports/pt_br.ex
igas Sep 10, 2024
05e24f3
Discard changes to lib/faker/app.ex
igas Sep 10, 2024
7937281
Discard changes to lib/faker/avatar.ex
igas Sep 10, 2024
ba0636d
Discard changes to lib/faker/aws/en.ex
igas Sep 10, 2024
bd461e4
Discard changes to lib/faker/aws/fr.ex
igas Sep 10, 2024
ed7635a
Discard changes to lib/faker/aws/pt_br.ex
igas Sep 10, 2024
3c40da7
Discard changes to lib/faker/aws/pt_pt.ex
igas Sep 10, 2024
7638e5e
Discard changes to lib/faker/beer.ex
igas Sep 10, 2024
4278528
Discard changes to lib/faker/beer/en.ex
igas Sep 10, 2024
5641675
Discard changes to lib/faker/blockchain/bitcoin.ex
igas Sep 10, 2024
5d5cb8b
Discard changes to lib/faker/blockchain/ethereum.ex
igas Sep 10, 2024
9f7ba0d
Discard changes to lib/faker/cannabis.ex
igas Sep 10, 2024
fc062f5
Discard changes to lib/faker/cannabis/en.ex
igas Sep 10, 2024
2221d4f
Discard changes to lib/faker/cat.ex
igas Sep 10, 2024
bc6674b
Discard changes to lib/faker/cat/en.ex
igas Sep 10, 2024
cccdaa1
Discard changes to lib/faker/cat/pt_br.ex
igas Sep 10, 2024
2b64734
Discard changes to lib/faker/code.ex
igas Sep 10, 2024
dbbd7cf
Discard changes to lib/faker/code/iban.ex
igas Sep 10, 2024
2dc7e83
Discard changes to lib/faker/color.ex
igas Sep 10, 2024
1a83086
Discard changes to lib/faker/food.ex
igas Sep 10, 2024
f5eff24
Discard changes to lib/faker/food/pt_br.ex
igas Sep 10, 2024
d1785cc
Discard changes to lib/faker/food/hy.ex
igas Sep 10, 2024
966a597
Discard changes to lib/faker/color/de.ex
igas Sep 10, 2024
3e2e7b6
Discard changes to lib/faker/color/en.ex
igas Sep 10, 2024
c08bac1
Discard changes to lib/faker/color/es.ex
igas Sep 10, 2024
b12ab8c
Discard changes to lib/faker/color/hy.ex
igas Sep 10, 2024
a056efe
Discard changes to lib/faker/color/fr.ex
igas Sep 10, 2024
27ab114
Discard changes to lib/faker/color/it.ex
igas Sep 10, 2024
c016112
Discard changes to lib/faker/color/pt_br.ex
igas Sep 10, 2024
e146ca5
Discard changes to lib/faker/currency.ex
igas Sep 10, 2024
4ef822b
Discard changes to lib/faker/internet/status_code.ex
igas Sep 10, 2024
40da2bc
Discard changes to lib/faker/internet/user_agent.ex
igas Sep 10, 2024
04ec155
Discard changes to lib/faker/internet/pt_br.ex
igas Sep 10, 2024
dd812a8
Discard changes to lib/faker/internet.ex
igas Sep 10, 2024
477a5d7
Discard changes to lib/faker/commerce.ex
igas Sep 10, 2024
2aa2cfa
Discard changes to lib/faker/commerce/pt_br.ex
igas Sep 10, 2024
9e638c5
Discard changes to lib/faker/commerce/en.ex
igas Sep 10, 2024
850f397
Discard changes to lib/faker/company/en.ex
igas Sep 10, 2024
1f6652a
Discard changes to lib/faker/company/hy.ex
igas Sep 10, 2024
95b852e
Discard changes to lib/faker/food/en.ex
igas Sep 10, 2024
4a27ea5
Discard changes to lib/faker/company.ex
igas Sep 10, 2024
c96c0fc
Discard changes to lib/faker/dog/pt_br.ex
igas Sep 10, 2024
9e0fa7b
oh man
igas Sep 10, 2024
ec22554
Merge branch 'master' into tests-compatible-elixir-1.17
igas Sep 10, 2024
aa41dbc
fix: rest
igas Sep 11, 2024
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
23 changes: 18 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,21 @@ jobs:
- elixir: 1.15.x
otp: 25.x
os: ubuntu-20.04
# Something changed in otp 26 for seed and single test started producing failures
# it does not affect functionality, only CI
# - elixir: 1.15.x
# otp: 26.x
# os: ubuntu-20.04
- elixir: 1.16.x
otp: 24.x
os: ubuntu-20.04
igas marked this conversation as resolved.
Show resolved Hide resolved
- elixir: 1.16.x
otp: 25.x
os: ubuntu-20.04
- elixir: 1.16.x
otp: 26.x
os: ubuntu-20.04
- elixir: 1.17.x
otp: 25.x
os: ubuntu-22.04
- elixir: 1.17.x
otp: 26.x
os: ubuntu-22.04
- elixir: 1.17.x
otp: 27.x
os: ubuntu-22.04
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Change log itself follows [Keep a CHANGELOG](http://keepachangelog.com) format.

### Added

- Test with Elixir 1.16 and 1.17 on CI [[@ypconstante](https://github.com/ypconstante)]
- Test with OTP 26 and 27 on CI [[@ypconstante](https://github.com/ypconstante)]

### Changed

### Deprecated
Expand All @@ -19,6 +22,7 @@ Change log itself follows [Keep a CHANGELOG](http://keepachangelog.com) format.
### Fixed

- Fix compile and runtime warnings on Elixir 1.17 [[@ypconstante](https://github.com/ypconstante)]
- `Faker.Internet.slug` and `Faker.Markdown.markdown/0` results won't change between Elixir versions [[@ypconstante](https://github.com/ypconstante)]

### Security

Expand Down
4 changes: 2 additions & 2 deletions lib/faker/file.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ defmodule Faker.File do
~w(video/mpeg video/mp4 video/ogg video/quicktime video/webm video/x-matroska video/x-ms-wmv video/x-flv)
}

@categories_extensions Map.keys(@extensions)
@categories_mimes Map.keys(@mimes)
@categories_extensions @extensions |> Map.keys() |> Enum.sort()
@categories_mimes @mimes |> Map.keys() |> Enum.sort()

@doc """
Returns a random file extension
Expand Down
10 changes: 5 additions & 5 deletions lib/faker/internet.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Faker.Internet do
alias Faker.Util

import Faker.Util, only: [pick: 1]
import Faker, only: [localize: 1]
import Faker, only: [localize: 1, random_uniform: 0]

@moduledoc """
Functions for generating internet related data
Expand Down Expand Up @@ -292,11 +292,11 @@ defmodule Faker.Internet do
## Examples

iex> Faker.Internet.slug()
"sint-deleniti-consequatur-ut"
"deleniti-sint-consequatur-ut"
iex> Faker.Internet.slug()
"sit_et"
"cumque_sit_aut_expedita"
iex> Faker.Internet.slug(["foo", "bar"])
"foo-bar"
"foo_bar"
iex> Faker.Internet.slug(["foo", "bar"], ["."])
"foo.bar"
"""
Expand All @@ -313,7 +313,7 @@ defmodule Faker.Internet do
@spec slug([String.t()], [String.t()]) :: String.t()
def slug(words, glue) do
words
|> Enum.take_random(length(words))
|> Enum.sort_by(fn _ -> random_uniform() end)
|> Enum.join(pick(glue))
|> String.downcase()
end
Expand Down
12 changes: 6 additions & 6 deletions lib/faker/markdown.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defmodule Faker.Markdown do
import Faker, only: [random_between: 2]
import Faker, only: [random_between: 2, random_uniform: 0]

alias Faker.Lorem
alias Faker.Util
Expand Down Expand Up @@ -191,13 +191,13 @@ defmodule Faker.Markdown do
## Examples

iex> Faker.Markdown.markdown()
"cumque | est | necessitatibus\\n---- | ---- | ----\\nbeatae | ex | sunt\\nsoluta | possimus | soluta\\nasperiores | qui | vitae\\n\\n* Et vitae vitae ut quisquam corporis quisquam ab harum ipsa.\\n* Numquam maxime ut aut inventore eius rerum beatae.\\n* Qui officia vel quaerat expedita.\\n* Perspiciatis rerum nam repellendus inventore nihil.\\n\\n`Sequi ducimus qui voluptates magni quisquam sed odio.`\\n\\n```elixir\\nError non impedit tempora minus voluptatem qui fugit.\\n```\\n\\n### Cupiditate"
"## Aut\\n\\n```ruby\\nBeatae ex sunt soluta possimus soluta asperiores qui vitae animi.\\n```\\n\\n`Et vitae vitae ut quisquam corporis quisquam ab harum ipsa.`\\n\\n* Maxime ut aut inventore eius rerum beatae?\\n* Qui officia vel quaerat expedita.\\n* Perspiciatis rerum nam repellendus inventore nihil.\\n* Sequi ducimus qui voluptates magni quisquam sed odio.\\n* Vel error non impedit tempora minus.\\n\\nfugit | cupiditate | fuga | ab\\n---- | ---- | ---- | ----\\nconsectetur | harum | earum | possimus\\ntotam | nobis | provident | quisquam\\nmodi | accusantium | eligendi | numquam"
iex> Faker.Markdown.markdown()
"_Illo_ voluptas quod blanditiis est non id quibusdam qui omnis. Odit dicta dolores at ut delectus magni atque eos? Labore voluptate laudantium qui.\\n\\n### Voluptatibus\\n\\nullam | similique | minima | laudantium\\n---- | ---- | ---- | ----\\nvoluptate | reiciendis | repellat | et\\npraesentium | quia | sed | nemo\\nminus | ea | vero | repellat\\ncumque | nihil | similique | repudiandae\\ncorrupti | rerum | sed | similique\\naccusamus | suscipit | perspiciatis | cum"
"Odit dicta dolores at ut delectus magni atque eos? Labore voluptate laudantium ~qui.~ Voluptatibus sed et enim ullam?\\n\\n1. Repellat et praesentium quia sed nemo minus ea!\\n2. Cumque nihil similique repudiandae corrupti!\\n3. Similique accusamus suscipit perspiciatis cum.\\n4. Dolore et ut earum possimus eos reprehenderit cupiditate omnis et.\\n5. Sit delectus possimus quo et est culpa eum ex?\\n6. Aut aut aut quisquam?\\n7. Tenetur alias est provident esse dicta ea illo consequatur maiores?"
iex> Faker.Markdown.markdown()
"```erlang\\nSit delectus possimus quo et est culpa eum ex?\\n```\\n\\n1. Aut aut quisquam labore fuga tenetur alias.\\n2. Esse dicta ea illo consequatur!\\n3. Et quia culpa sunt sit eius cumque porro ut eum.\\n4. Id maxime dolorum animi!\\n5. Deserunt ipsa consequuntur eveniet asperiores.\\n6. Quia numquam voluptas vitae repellat tempore.\\n7. Harum voluptas harum modi omnis quam dolor a aliquam officiis?\\n8. Neque voluptas consequatur sed cupiditate dolorum pariatur et.\\n9. Aut voluptatem natus amet eius eos non dolorum.\\n\\n`Pariatur ex illo aliquam rerum ab voluptatem exercitationem nobis enim.`\\n\\nCorporis **unde** ex enim dolore ut consequuntur eaque! Eius totam nobis est."
"* Porro est id maxime dolorum animi.\\n* Deserunt ipsa consequuntur eveniet asperiores.\\n* Quia numquam voluptas vitae repellat tempore.\\n* Harum voluptas harum modi omnis quam dolor a aliquam officiis?\\n* Neque voluptas consequatur sed cupiditate dolorum pariatur et.\\n* Aut voluptatem natus amet eius eos non dolorum.\\n* Pariatur ex illo aliquam rerum ab voluptatem exercitationem nobis enim.\\n* Eos corporis unde ex enim dolore ut consequuntur.\\n* Dicta eius totam nobis est a eveniet ab magni.\\n* Consequatur unde dolorem et nihil laudantium ea veniam necessitatibus."
iex> Faker.Markdown.markdown()
"Qui iusto quisquam minus ad omnis quaerat quidem _impedit!_ Qui id ut repellat qui repudiandae quia cumque excepturi laudantium.\\n\\n`Non consequatur molestiae laboriosam sit!`\\n\\n## Aperiam"
"1. Repellat qui repudiandae quia cumque excepturi laudantium accusantium!\\n2. Sunt non consequatur molestiae laboriosam sit aperiam.\\n3. Voluptatem est beatae delectus minus qui molestiae dolorem aut.\\n4. Iure enim sapiente quia voluptas esse!\\n\\n```go\\nVoluptas ullam ratione et esse optio qui ut sed dignissimos!\\n```\\n\\nsaepe | a | illo\\n---- | ---- | ----\\nut | eos | aliquid\\nquisquam | omnis | magni\\nconsequuntur | molestiae | expedita\\n\\n* Ducimus est nulla repellat reiciendis est est veritatis.\\n* Quaerat assumenda ut reiciendis eaque in!\\n* Aliquam quis sapiente facere?\\n* Nihil suscipit pariatur qui."
"""
@spec markdown() :: String.t()
def markdown do
Expand All @@ -213,7 +213,7 @@ defmodule Faker.Markdown do
|> Enum.filter(fn _ ->
Util.pick([true, false])
end)
|> Enum.shuffle()
|> Enum.sort_by(fn _ -> random_uniform() end)
|> Stream.map(fn fun ->
apply(__MODULE__, fun, [])
end)
Expand Down
16 changes: 8 additions & 8 deletions lib/faker/phone/en_gb.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ defmodule Faker.Phone.EnGb do
## Examples

iex> Faker.Phone.EnGb.number()
"+44054264610"
"+44042646108"
iex> Faker.Phone.EnGb.number()
"+44562970523"
"07897 052357"
iex> Faker.Phone.EnGb.number()
"+447502 030320"
"+44803032097"
iex> Faker.Phone.EnGb.number()
"+447933 760337"
"+447776 033745"
"""
@spec number() :: String.t()
def number do
Expand All @@ -54,13 +54,13 @@ defmodule Faker.Phone.EnGb do
## Examples

iex> Faker.Phone.EnGb.landline_number()
"+44331542646"
"+44335426461"
iex> Faker.Phone.EnGb.landline_number()
"+44560832970"
"+44343297052"
iex> Faker.Phone.EnGb.landline_number()
"+44023570203"
"+44567020303"
iex> Faker.Phone.EnGb.landline_number()
"+44703209733"
"+44709733760"
"""
@spec landline_number() :: String.t()
def landline_number do
Expand Down
4 changes: 2 additions & 2 deletions lib/faker/random/test.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ defmodule Faker.Random.Test do

def random_between(left, right) do
set_seed(:ets.lookup(:seed_registry, self()))
Enum.random(left..right)
left + :rand.uniform(right - left + 1) - 1
end

def random_bytes(total) do
set_seed(:ets.lookup(:seed_registry, self()))

Stream.repeatedly(fn -> Enum.random(0..255) end)
Stream.repeatedly(fn -> random_between(0, 255) end)
|> Enum.take(total)
|> IO.iodata_to_binary()
end
Expand Down
8 changes: 4 additions & 4 deletions lib/faker/vehicle.ex
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,13 @@ defmodule Faker.Vehicle do

## Examples
iex> Faker.Vehicle.vin()
"1C68203VCV0360337"
"1C689K5Y000T03374"
iex> Faker.Vehicle.vin()
"5190V7FL8YX113016"
"D0B19RGCD90H16449"
iex> Faker.Vehicle.vin()
"4RSE9035H9JA97940"
"RSE90354760B00530"
iex> Faker.Vehicle.vin()
"59E4A13G890C97377"
"L9Z63TST830A76983"
"""
def vin do
Util.format("%10x%y%x%5d",
Expand Down
Loading