Skip to content

Commit c228e0b

Browse files
committed
test: fix tests & update tag/regression test
1 parent e1adfac commit c228e0b

File tree

4 files changed

+172
-8
lines changed

4 files changed

+172
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
{
2+
"attributes": [
3+
{
4+
"allow_nil?": false,
5+
"default": "fragment(\"gen_random_uuid()\")",
6+
"generated?": false,
7+
"primary_key?": true,
8+
"references": null,
9+
"size": null,
10+
"source": "id",
11+
"type": "uuid"
12+
},
13+
{
14+
"allow_nil?": true,
15+
"default": "nil",
16+
"generated?": false,
17+
"primary_key?": false,
18+
"references": null,
19+
"size": null,
20+
"source": "is_active",
21+
"type": "boolean"
22+
},
23+
{
24+
"allow_nil?": true,
25+
"default": "nil",
26+
"generated?": false,
27+
"primary_key?": false,
28+
"references": null,
29+
"size": null,
30+
"source": "name",
31+
"type": "text"
32+
},
33+
{
34+
"allow_nil?": true,
35+
"default": "\"user\"",
36+
"generated?": false,
37+
"primary_key?": false,
38+
"references": null,
39+
"size": null,
40+
"source": "role",
41+
"type": "text"
42+
},
43+
{
44+
"allow_nil?": true,
45+
"default": "[]",
46+
"generated?": false,
47+
"primary_key?": false,
48+
"references": null,
49+
"size": null,
50+
"source": "role_list",
51+
"type": [
52+
"array",
53+
"text"
54+
]
55+
},
56+
{
57+
"allow_nil?": true,
58+
"default": "nil",
59+
"generated?": false,
60+
"primary_key?": false,
61+
"references": {
62+
"deferrable": false,
63+
"destination_attribute": "id",
64+
"destination_attribute_default": null,
65+
"destination_attribute_generated": null,
66+
"index?": false,
67+
"match_type": null,
68+
"match_with": null,
69+
"multitenancy": {
70+
"attribute": null,
71+
"global": null,
72+
"strategy": null
73+
},
74+
"name": "users_organization_id_fkey",
75+
"on_delete": null,
76+
"on_update": null,
77+
"primary_key?": true,
78+
"schema": "public",
79+
"table": "orgs"
80+
},
81+
"size": null,
82+
"source": "organization_id",
83+
"type": "uuid"
84+
},
85+
{
86+
"allow_nil?": true,
87+
"default": "nil",
88+
"generated?": false,
89+
"primary_key?": false,
90+
"references": {
91+
"deferrable": false,
92+
"destination_attribute": "id",
93+
"destination_attribute_default": null,
94+
"destination_attribute_generated": null,
95+
"index?": false,
96+
"match_type": null,
97+
"match_with": null,
98+
"multitenancy": {
99+
"attribute": "id",
100+
"global": true,
101+
"strategy": "attribute"
102+
},
103+
"name": "users_org_id_fkey",
104+
"on_delete": null,
105+
"on_update": null,
106+
"primary_key?": true,
107+
"schema": "public",
108+
"table": "multitenant_orgs"
109+
},
110+
"size": null,
111+
"source": "org_id",
112+
"type": "uuid"
113+
}
114+
],
115+
"base_filter": null,
116+
"check_constraints": [],
117+
"custom_indexes": [],
118+
"custom_statements": [],
119+
"has_create_action": true,
120+
"hash": "8DC96004D53169EA4AA3721AD7836DB2A230F30C55EE1B06DDB1D7505AE50210",
121+
"identities": [],
122+
"multitenancy": {
123+
"attribute": null,
124+
"global": null,
125+
"strategy": null
126+
},
127+
"repo": "Elixir.AshPostgres.TestRepo",
128+
"schema": null,
129+
"table": "users"
130+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
defmodule AshPostgres.TestRepo.Migrations.MigrateResources52 do
2+
@moduledoc """
3+
Updates resources based on their most recent snapshots.
4+
5+
This file was autogenerated with `mix ash_postgres.generate_migrations`
6+
"""
7+
8+
use Ecto.Migration
9+
10+
def up do
11+
alter table(:users) do
12+
modify(:role_list, {:array, :text}, null: true)
13+
modify(:role, :text, null: true)
14+
15+
add(
16+
:org_id,
17+
references(:multitenant_orgs,
18+
column: :id,
19+
name: "users_org_id_fkey",
20+
type: :uuid,
21+
prefix: "public"
22+
)
23+
)
24+
end
25+
end
26+
27+
def down do
28+
drop(constraint(:users, "users_org_id_fkey"))
29+
30+
alter table(:users) do
31+
remove(:org_id)
32+
modify(:role, :text, null: false)
33+
modify(:role_list, {:array, :text}, null: false)
34+
end
35+
end
36+
end

Diff for: test/bulk_update_test.exs

+5-6
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ defmodule AshPostgres.BulkUpdateTest do
264264
)
265265
end
266266

267-
@tag :wip
267+
@tag :regression
268268
test "jsonb[] attribute with embedded Resource definition can be created and updated" do
269269
%{status: :success} =
270270
Ash.bulk_create!(
@@ -275,10 +275,9 @@ defmodule AshPostgres.BulkUpdateTest do
275275
return_errors?: true
276276
)
277277

278-
%{status: :success} =
279-
Ash.bulk_update(CSV, :update, %{
280-
column_mapping_embedded: [%{column: 1, attribute: "foo"}],
281-
column_mapping_new_type: [%{column: 1, attribute: "foo"}]
282-
})
278+
Ash.bulk_update!(CSV, :update, %{
279+
column_mapping_embedded: [%{column: 1, attribute: "foo"}],
280+
column_mapping_new_type: [%{column: 1, attribute: "foo"}]
281+
})
283282
end
284283
end

Diff for: test/support/resources/csv.ex

+1-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ defmodule AshPostgres.Test.CSV do
5050
table "csv"
5151
repo(AshPostgres.TestRepo)
5252

53-
storage_types column_mapping_embedded: :jsonb
54-
storage_types column_mapping_new_type: :jsonb
53+
storage_types column_mapping_embedded: :jsonb, column_mapping_new_type: :jsonb
5554
end
5655
end

0 commit comments

Comments
 (0)