Add a generator for Link with random shorten.
This commit is contained in:
@@ -44,3 +44,5 @@
|
|||||||
Add the CI/CD configuration.
|
Add the CI/CD configuration.
|
||||||
Add the test config.
|
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
|
||||||
Reference in New Issue
Block a user