Add a generator for Link with random shorten.

This commit is contained in:
2023-08-04 21:10:08 +03:00
parent ecdce9e407
commit feebbe4f8a
2 changed files with 16 additions and 0 deletions
+2
View File
@@ -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