Add a generator for Link with random shorten.

main
KKlochko 2 years ago
parent ecdce9e407
commit feebbe4f8a

@ -44,3 +44,5 @@
Add the CI/CD configuration.
Add the test config.
** 0.5.1 <2023-08-04 Fri>
Add a generator for Link with random shorten.

@ -0,0 +1,14 @@
defmodule LinkShortener.Generators.LinkWithRandomShorten do
@moduledoc """
This module provides a generator for Link.
"""
alias LinkShortener.Generators.SafeString
@doc """
Generate a Link with random shorten with the length.
"""
def generate_one(attrs, length \\ 10, generator \\ &SafeString.generate/1) do
Map.put(attrs, :shorten, generator.(length))
end
end
Loading…
Cancel
Save