Skip to content

Commit

Permalink
Add a failing test to cover auto enum generation
Browse files Browse the repository at this point in the history
  • Loading branch information
ahey committed Jan 3, 2023
1 parent c62d1d5 commit 5215658
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions test/attribute_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
defmodule AshGraphql.AttributeTest do
use ExUnit.Case, async: false

setup do
Application.delete_env(:ash_graphql, AshGraphql.Test.Api)

on_exit(fn ->
try do
AshGraphql.TestHelpers.stop_ets()
rescue
_ ->
:ok
end
end)
end

test "atom attribute with one_of constraints has enums automatically generated" do
{:ok, %{data: data}} =
"""
query {
__type(name: "Visibility") {
enumValues {
name
}
}
}
"""
|> Absinthe.run(AshGraphql.Test.Schema)

assert data["__type"]
end
end
2 changes: 1 addition & 1 deletion test/support/resources/post.ex
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ defmodule AshGraphql.Test.Post do
attribute(:embed, AshGraphql.Test.Embed)
attribute(:text1, :string)
attribute(:text2, :string)

attribute(:visibility, :atom, constraints: [one_of: [:public, :private]])
create_timestamp(:created_at, private?: false)
end

Expand Down

0 comments on commit 5215658

Please sign in to comment.