fix: add test for string generator, and fix it

This commit is contained in:
Zach Daniel 2022-12-20 20:42:41 -05:00
parent ad2392be99
commit 5da64349c6
2 changed files with 7 additions and 1 deletions

View file

@ -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

View file

@ -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