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 all 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
68 changes: 24 additions & 44 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- run: mix credo --strict --format=sarif

# dialyzer:
# runs-on: ${{ matrix.os || 'ubuntu-20.04' }}
# runs-on: ${{ matrix.os || 'ubuntu-22.04' }}

# steps:
# - uses: actions/[email protected]
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
# - run: mix dialyzer --format github

test:
runs-on: ${{ matrix.os || 'ubuntu-20.04' }}
runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
Expand All @@ -70,50 +70,30 @@ jobs:
fail-fast: false
matrix:
include:
- elixir: 1.11.x
otp: 21.x
os: ubuntu-20.04
- elixir: 1.11.x
otp: 22.x
os: ubuntu-20.04
- elixir: 1.11.x
otp: 23.x
os: ubuntu-20.04
- elixir: 1.12.x
otp: 22.x
os: ubuntu-20.04
- elixir: 1.12.x
otp: 23.x
os: ubuntu-20.04
- elixir: 1.12.x
otp: 24.x
os: ubuntu-20.04
- elixir: 1.13.x
otp: 22.x
os: ubuntu-20.04
- elixir: 1.13.x
otp: 23.x
os: ubuntu-20.04
- elixir: 1.13.x
otp: 24.x
os: ubuntu-20.04
- elixir: 1.14.x
otp: 23.x
os: ubuntu-20.04
- elixir: 1.14.x
- elixir: 1.15.x
otp: 24.x
os: ubuntu-20.04
- elixir: 1.14.x
os: ubuntu-24.04
- elixir: 1.15.x
otp: 25.x
os: ubuntu-20.04
os: ubuntu-24.04
- elixir: 1.15.x
otp: 26.x
os: ubuntu-24.04
- elixir: 1.16.x
otp: 24.x
os: ubuntu-20.04
- elixir: 1.15.x
os: ubuntu-24.04
- elixir: 1.16.x
otp: 25.x
os: ubuntu-24.04
- elixir: 1.16.x
otp: 26.x
os: ubuntu-24.04
- elixir: 1.17.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
os: ubuntu-24.04
- elixir: 1.17.x
otp: 26.x
os: ubuntu-24.04
- elixir: 1.17.x
otp: 27.x
os: ubuntu-24.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
8 changes: 8 additions & 0 deletions lib/faker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ defmodule Faker do
Application.get_env(:faker, :random_module).random_bytes(total)
end

@doc """
Returns a shuffled enum.
"""
@spec shuffle(Enum.t()) :: list()
def shuffle(enum) do
Application.get_env(:faker, :random_module).shuffle(enum)
end

defmacro localize(function) do
quote do
def unquote(function)() do
Expand Down
36 changes: 0 additions & 36 deletions lib/faker/commerce/hy.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ defmodule Faker.Commerce.Hy do

iex> Faker.Commerce.Hy.color()
"մոխրագույն"
iex> Faker.Commerce.Hy.color()
"կանաչ"
iex> Faker.Commerce.Hy.color()
"երկնագույն"
iex> Faker.Commerce.Hy.color()
"մանուշակագույն"
"""
@spec color() :: String.t()
def color do
Expand All @@ -32,12 +26,6 @@ defmodule Faker.Commerce.Hy do

iex> Faker.Commerce.Hy.department()
"Համակարգիչներ"
iex> Faker.Commerce.Hy.department()
"Երաժշտություն"
iex> Faker.Commerce.Hy.department()
"Գրքեր"
iex> Faker.Commerce.Hy.department()
"Էլեկտրոնիկա"
"""
@spec department() :: String.t()
sampler(:department, [
Expand Down Expand Up @@ -72,12 +60,6 @@ defmodule Faker.Commerce.Hy do

iex> Faker.Commerce.Hy.product_name()
"հիանալի բրոնզե գլխարկ"
iex> Faker.Commerce.Hy.product_name()
"ֆանտաստիկ դանակ"
iex> Faker.Commerce.Hy.product_name()
"պլաստիկից աթոռ"
iex> Faker.Commerce.Hy.product_name()
"ալյումինե վերնաշապիկ"
"""
@spec product_name() :: String.t()
def product_name, do: product_name(Faker.random_between(0, 2))
Expand All @@ -96,12 +78,6 @@ defmodule Faker.Commerce.Hy do

iex> Faker.Commerce.Hy.product_name_adjective()
"ֆանտաստիկ"
iex> Faker.Commerce.Hy.product_name_adjective()
"հիանալի"
iex> Faker.Commerce.Hy.product_name_adjective()
"միջակ"
iex> Faker.Commerce.Hy.product_name_adjective()
"նրբագեղ"
"""
@spec product_name_adjective() :: String.t()
sampler(:product_name_adjective, [
Expand Down Expand Up @@ -130,12 +106,6 @@ defmodule Faker.Commerce.Hy do

iex> Faker.Commerce.Hy.product_name_material()
"փայտե"
iex> Faker.Commerce.Hy.product_name_material()
"գրանիտե"
iex> Faker.Commerce.Hy.product_name_material()
"բրոնզե"
iex> Faker.Commerce.Hy.product_name_material()
"մարմարե"
"""
@spec product_name_material() :: String.t()
sampler(:product_name_material, [
Expand Down Expand Up @@ -165,12 +135,6 @@ defmodule Faker.Commerce.Hy do

iex> Faker.Commerce.Hy.product_name_product()
"վերնաշապիկ"
iex> Faker.Commerce.Hy.product_name_product()
"ստեղնաշար"
iex> Faker.Commerce.Hy.product_name_product()
"վերնաշապիկ"
iex> Faker.Commerce.Hy.product_name_product()
"գլխարկ"
"""
@spec product_name_product() :: String.t()
sampler(:product_name_product, [
Expand Down
39 changes: 4 additions & 35 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 All @@ -40,12 +40,6 @@ defmodule Faker.File do

iex> Faker.File.file_extension()
"wav"
iex> Faker.File.file_extension()
"wav"
iex> Faker.File.file_extension()
"doc"
iex> Faker.File.file_extension()
"mov"
"""
@spec file_extension() :: String.t()
def file_extension do
Expand All @@ -62,12 +56,9 @@ defmodule Faker.File do

iex> Faker.File.file_extension(:video)
"mov"

iex> Faker.File.file_extension(:image)
"tiff"
iex> Faker.File.file_extension(:audio)
"flac"
iex> Faker.File.file_extension(:office)
"xls"
"bmp"
"""
@spec file_extension(atom) :: String.t()
def file_extension(category) do
Expand All @@ -83,12 +74,6 @@ defmodule Faker.File do

iex> Faker.File.file_name()
"aliquam.jpg"
iex> Faker.File.file_name()
"deleniti.doc"
iex> Faker.File.file_name()
"qui.jpg"
iex> Faker.File.file_name()
"quibusdam.csv"
"""
@spec file_name() :: String.t()
def file_name do
Expand All @@ -105,10 +90,6 @@ defmodule Faker.File do
"aliquam.txt"
iex> Faker.File.file_name(:video)
"sint.mp4"
iex> Faker.File.file_name(:image)
"consequatur.bmp"
iex> Faker.File.file_name(:audio)
"qui.wav"
"""
@spec file_name(atom) :: String.t()
def file_name(category) do
Expand All @@ -122,12 +103,6 @@ defmodule Faker.File do

iex> Faker.File.mime_type()
"text/css"
iex> Faker.File.mime_type()
"message/http"
iex> Faker.File.mime_type()
"application/ogg"
iex> Faker.File.mime_type()
"model/x3d+xml"
"""
@spec mime_type :: String.t()
def mime_type do
Expand All @@ -145,12 +120,6 @@ defmodule Faker.File do

iex> Faker.File.mime_type(:image)
"image/vnd.microsoft.icon"
iex> Faker.File.mime_type(:audio)
"audio/mp4"
iex> Faker.File.mime_type(:application)
"application/xop+xml"
iex> Faker.File.mime_type(:video)
"video/mpeg"
"""
@spec mime_type(atom) :: String.t()
def mime_type(category) do
Expand Down
21 changes: 2 additions & 19 deletions lib/faker/finance/stock.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ defmodule Faker.Finance.Stock do

iex> Faker.Finance.Stock.ticker()
"7401.N225"
iex> Faker.Finance.Stock.ticker()
"4786.HK"
iex> Faker.Finance.Stock.ticker()
"6766.N225"
iex> Faker.Finance.Stock.ticker()
"5166.N225"
"""
@spec ticker() :: String.t()
def ticker do
Expand All @@ -34,20 +28,9 @@ defmodule Faker.Finance.Stock do

iex> Faker.Finance.Stock.ticker(:reuters, :nikkei225)
"2110.N225"
iex> Faker.Finance.Stock.ticker(:reuters, :nikkei225)
"7401.N225"
iex> Faker.Finance.Stock.ticker(:reuters, :nikkei225)
"9835.N225"
iex> Faker.Finance.Stock.ticker(:reuters, :nikkei225)
"8304.N225"
iex> Faker.Finance.Stock.ticker(:reuters, :sehk)
"7564.HK"
iex> Faker.Finance.Stock.ticker(:reuters, :sehk)
"3609.HK"
iex> Faker.Finance.Stock.ticker(:reuters, :sehk)
"1085.HK"

iex> Faker.Finance.Stock.ticker(:reuters, :sehk)
"5849.HK"
"8517.HK"
"""
def ticker(:reuters, :nikkei225) do
"#{Faker.random_between(1000, 9999)}.N225"
Expand Down
8 changes: 4 additions & 4 deletions lib/faker/fruit/en.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ defmodule Faker.Fruit.En do
@doc """
Returns a fruit.
## Examples
iex> Faker.Fruit.En.fruit
iex> Faker.Fruit.En.fruit()
"Kiwano"
iex> Faker.Fruit.En.fruit
iex> Faker.Fruit.En.fruit()
"Sugarcane"
iex> Faker.Fruit.En.fruit
iex> Faker.Fruit.En.fruit()
"Pineapple"
iex> Faker.Fruit.En.fruit
iex> Faker.Fruit.En.fruit()
"Lemon"
"""
@spec fruit() :: String.t()
Expand Down
8 changes: 4 additions & 4 deletions lib/faker/fruit/pt_br.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ defmodule Faker.Fruit.PtBr do

## Examples

iex> Faker.Fruit.PtBr.fruit
iex> Faker.Fruit.PtBr.fruit()
"Fruta-do-conde"
iex> Faker.Fruit.PtBr.fruit
iex> Faker.Fruit.PtBr.fruit()
"Bergamota"
iex> Faker.Fruit.PtBr.fruit
iex> Faker.Fruit.PtBr.fruit()
"Quixaba"
iex> Faker.Fruit.PtBr.fruit
iex> Faker.Fruit.PtBr.fruit()
"Amora"
"""
@spec fruit() :: String.t()
Expand Down
8 changes: 4 additions & 4 deletions lib/faker/gov/it.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ defmodule Faker.Gov.It do

## Examples

iex> Faker.Gov.It.fiscal_id
iex> Faker.Gov.It.fiscal_id()
"ELRCEA64C50A918F"
iex> Faker.Gov.It.fiscal_id
iex> Faker.Gov.It.fiscal_id()
"ZSLNKH22M34H480J"
iex> Faker.Gov.It.fiscal_id
iex> Faker.Gov.It.fiscal_id()
"OCPCVO90M50F353I"
iex> Faker.Gov.It.fiscal_id
iex> Faker.Gov.It.fiscal_id()
"PQYRFX94R54C681K"
"""
@spec fiscal_id() :: binary()
Expand Down
Loading
Loading