mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 05:23:03 +12:00
fix: add test for string generator, and fix it
This commit is contained in:
parent
ad2392be99
commit
5da64349c6
2 changed files with 7 additions and 1 deletions
|
@ -54,7 +54,7 @@ defmodule Ash.Type.String do
|
|||
|
||||
if constraints[:trim?] && constraints[:min_length] do
|
||||
StreamData.filter(base_generator, fn value ->
|
||||
value |> String.trim() |> String.length() |> Kernel.>(constraints[:min_length])
|
||||
value |> String.trim() |> String.length() |> Kernel.>=(constraints[:min_length])
|
||||
end)
|
||||
else
|
||||
base_generator
|
||||
|
|
|
@ -160,6 +160,12 @@ defmodule Ash.Test.GeneratorTest do
|
|||
end
|
||||
end
|
||||
|
||||
test "string generator honors trim?: true" do
|
||||
check all(string <- Ash.Type.String.generator(min_length: 5, trim?: true)) do
|
||||
assert String.length(String.trim(string)) >= 5
|
||||
end
|
||||
end
|
||||
|
||||
describe "changeset" do
|
||||
test "a directly usable changeset can be created" do
|
||||
Post
|
||||
|
|
Loading…
Reference in a new issue