Skip to content

Commit 9597011

Browse files
committed
Add test that asserts generated array attributes
1 parent 8706a41 commit 9597011

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

test/mix/tasks/ash.gen.resource_test.exs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,32 @@ defmodule Mix.Tasks.Ash.Gen.ResourceTest do
7979
""")
8080
end
8181

82+
test "generates array attributes with modifiers" do
83+
test_project()
84+
|> Igniter.compose_task("ash.gen.resource", [
85+
"MyApp.Blog.Post",
86+
"--attribute",
87+
"list_atom:atom:array:public,list_string:string:array:required"
88+
])
89+
|> assert_creates("lib/my_app/blog/post.ex", """
90+
defmodule MyApp.Blog.Post do
91+
use Ash.Resource,
92+
otp_app: :test,
93+
domain: MyApp.Blog
94+
95+
attributes do
96+
attribute :list_atom, {:array, :atom} do
97+
public?(true)
98+
end
99+
100+
attribute :list_string, {:array, :string} do
101+
allow_nil?(false)
102+
end
103+
end
104+
end
105+
""")
106+
end
107+
82108
test "generates attributes with custom types" do
83109
test_project()
84110
|> Igniter.compose_task("ash.gen.resource", [
@@ -751,12 +777,12 @@ defmodule Mix.Tasks.Ash.Gen.ResourceTest do
751777
752778
attributes do
753779
uuid_primary_key(:id)
754-
780+
755781
attribute :title, :string do
756782
public? true
757783
end
758784
end
759-
785+
760786
actions do
761787
defaults [:read]
762788
end

0 commit comments

Comments
 (0)