Skip to content

Commit 702ce5e

Browse files
committed
chore: update tests to account for warnings
1 parent 4021b73 commit 702ce5e

File tree

2 files changed

+65
-56
lines changed

2 files changed

+65
-56
lines changed

test/aggregate_test.exs

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
defmodule AshSql.AggregateTest do
22
use AshPostgres.RepoCase, async: false
3+
import ExUnit.CaptureIO
34
alias AshPostgres.Test.{Author, Comment, Organization, Post, Rating, User}
45

56
require Ash.Query
@@ -970,37 +971,41 @@ defmodule AshSql.AggregateTest do
970971
end
971972

972973
test "can't define multidimensional array aggregate types" do
973-
assert_raise Spark.Error.DslError, ~r/Aggregate not supported/, fn ->
974-
defmodule Foo do
975-
@moduledoc false
976-
use Ash.Resource,
977-
domain: nil,
978-
data_layer: AshPostgres.DataLayer
979-
980-
postgres do
981-
table("profile")
982-
repo(AshPostgres.TestRepo)
983-
end
974+
# This used to raise an error, but now should only emit a warning and allow the module to compile
975+
{_, io} =
976+
with_io(:stderr, fn ->
977+
defmodule Foo do
978+
@moduledoc false
979+
use Ash.Resource,
980+
domain: nil,
981+
data_layer: AshPostgres.DataLayer
982+
983+
postgres do
984+
table("profile")
985+
repo(AshPostgres.TestRepo)
986+
end
984987

985-
attributes do
986-
uuid_primary_key(:id, writable?: true)
987-
end
988+
attributes do
989+
uuid_primary_key(:id, writable?: true)
990+
end
988991

989-
actions do
990-
defaults([:create, :read, :update, :destroy])
991-
end
992+
actions do
993+
defaults([:create, :read, :update, :destroy])
994+
end
992995

993-
relationships do
994-
belongs_to(:author, AshPostgres.Test.Author) do
995-
public?(true)
996+
relationships do
997+
belongs_to(:author, AshPostgres.Test.Author) do
998+
public?(true)
999+
end
9961000
end
997-
end
9981001

999-
aggregates do
1000-
first(:author_badges, :author, :badges)
1002+
aggregates do
1003+
first(:author_badges, :author, :badges)
1004+
end
10011005
end
1002-
end
1003-
end
1006+
end)
1007+
1008+
assert io =~ "Aggregate not supported"
10041009
end
10051010

10061011
test "related aggregates can be filtered on" do

test/references_test.exs

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
defmodule AshPostgres.ReferencesTest do
22
use AshPostgres.RepoCase
3+
import ExUnit.CaptureIO
34

45
test "can't use match_type != :full when referencing an non-primary key index" do
56
Code.compiler_options(ignore_module_conflict: true)
@@ -66,44 +67,47 @@ defmodule AshPostgres.ReferencesTest do
6667
end
6768
end
6869

69-
assert_raise Spark.Error.DslError, ~r/Unsupported match_type./, fn ->
70-
defmodule UserThing do
71-
@moduledoc false
72-
use Ash.Resource,
73-
domain: nil,
74-
data_layer: AshPostgres.DataLayer
75-
76-
attributes do
77-
attribute(:id, :string, primary_key?: true, allow_nil?: false, public?: true)
78-
attribute(:name, :string, public?: true)
79-
attribute(:org_id, :uuid, public?: true)
80-
attribute(:foo_id, :uuid, public?: true)
81-
end
70+
{_, io} =
71+
with_io(:stderr, fn ->
72+
defmodule UserThing do
73+
@moduledoc false
74+
use Ash.Resource,
75+
domain: nil,
76+
data_layer: AshPostgres.DataLayer
77+
78+
attributes do
79+
attribute(:id, :string, primary_key?: true, allow_nil?: false, public?: true)
80+
attribute(:name, :string, public?: true)
81+
attribute(:org_id, :uuid, public?: true)
82+
attribute(:foo_id, :uuid, public?: true)
83+
end
8284

83-
multitenancy do
84-
strategy(:attribute)
85-
attribute(:org_id)
86-
end
85+
multitenancy do
86+
strategy(:attribute)
87+
attribute(:org_id)
88+
end
8789

88-
relationships do
89-
belongs_to(:org, Org)
90-
belongs_to(:user, User, destination_attribute: :secondary_id)
91-
end
90+
relationships do
91+
belongs_to(:org, Org)
92+
belongs_to(:user, User, destination_attribute: :secondary_id)
93+
end
9294

93-
postgres do
94-
table("user_things")
95-
repo(AshPostgres.TestRepo)
95+
postgres do
96+
table("user_things")
97+
repo(AshPostgres.TestRepo)
9698

97-
references do
98-
reference :user, match_with: [foo_id: :foo_id], match_type: :simple
99+
references do
100+
reference :user, match_with: [foo_id: :foo_id], match_type: :simple
101+
end
99102
end
100-
end
101103

102-
actions do
103-
defaults([:create, :read, :update, :destroy])
104+
actions do
105+
defaults([:create, :read, :update, :destroy])
106+
end
104107
end
105-
end
106-
end
108+
end)
109+
110+
assert io =~ "Unsupported match_type"
107111
end
108112

109113
test "named reference results in properly applied foreign_key_constraint/3 on the underlying changeset" do

0 commit comments

Comments
 (0)