Skip to content

Commit 6e29a4d

Browse files
committed
test: test new start_of_day logic from ash core
this test won't pass until ash is updated
1 parent ac3d0fa commit 6e29a4d

File tree

5 files changed

+11
-1
lines changed

5 files changed

+11
-1
lines changed

Diff for: config/config.exs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ if Mix.env() == :dev do
1818
end
1919

2020
if Mix.env() == :test do
21+
config :elixir, :time_zone_database, Tz.TimeZoneDatabase
2122
config :ash_postgres, AshPostgres.TestRepo, log: false
2223
config :ash_postgres, AshPostgres.TestNoSandboxRepo, log: false
2324

Diff for: mix.exs

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ defmodule AshPostgres.MixProject do
173173
{:jason, "~> 1.0"},
174174
{:postgrex, ">= 0.0.0"},
175175
# dev/test dependencies
176+
{:tz, "~> 0.28.1"},
176177
{:ecto_dev_logger, "~> 0.14", only: :test},
177178
{:eflame, "~> 1.0", only: [:dev, :test]},
178179
{:simple_sat, "~> 0.1", only: [:dev, :test]},

Diff for: mix.lock

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%{
22
"ash": {:hex, :ash, "3.4.60", "c5002ffde3ef108ca24faa44702573c6e64afe3dfe5a670a5253d252c93aecae", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7", [hex: :ecto, repo: "hexpm", optional: false]}, {:ets, "~> 0.8", [hex: :ets, repo: "hexpm", optional: false]}, {:igniter, ">= 0.4.8 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:owl, "~> 0.11", [hex: :owl, repo: "hexpm", optional: false]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: true]}, {:plug, ">= 0.0.0", [hex: :plug, repo: "hexpm", optional: true]}, {:reactor, "~> 0.9", [hex: :reactor, repo: "hexpm", optional: false]}, {:simple_sat, ">= 0.1.1 and < 1.0.0-0", [hex: :simple_sat, repo: "hexpm", optional: true]}, {:spark, ">= 2.2.29 and < 3.0.0-0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, ">= 0.2.6 and < 1.0.0-0", [hex: :splode, repo: "hexpm", optional: false]}, {:stream_data, "~> 1.0", [hex: :stream_data, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "1b8e983f9cb973ed3300cd8fa261b136c0c389f8f51bee728cccc57edbe91a94"},
3-
"ash_sql": {:hex, :ash_sql, "0.2.48", "aea787441e97f9aaffe954e6f0f3b2d6206241d92bb104daf12b178befd65a1f", [:mix], [{:ash, ">= 3.1.7 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:ecto, "~> 3.9", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.9", [hex: :ecto_sql, repo: "hexpm", optional: false]}], "hexpm", "b19c5d3bc89cc6575f87ebfa57db33d697831df54a812589b9f4638b8b94864b"},
3+
"ash_sql": {:hex, :ash_sql, "0.2.49", "9c8a063d0ff9ee5b87716d4719751cee9224aae96ff59258621d3524c2aecdc6", [:mix], [{:ash, ">= 3.4.60 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:ecto, "~> 3.9", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.9", [hex: :ecto_sql, repo: "hexpm", optional: false]}], "hexpm", "681e8c98ea8f23cd406e9ed0ed09822fa7f08eaf9196d8acb092b9815ae0921d"},
44
"benchee": {:hex, :benchee, "1.3.1", "c786e6a76321121a44229dde3988fc772bca73ea75170a73fd5f4ddf1af95ccf", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}, {:statistex, "~> 1.0", [hex: :statistex, repo: "hexpm", optional: false]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "76224c58ea1d0391c8309a8ecbfe27d71062878f59bd41a390266bf4ac1cc56d"},
55
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
66
"credo": {:hex, :credo, "1.7.11", "d3e805f7ddf6c9c854fd36f089649d7cf6ba74c42bc3795d587814e3c9847102", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "56826b4306843253a66e47ae45e98e7d284ee1f95d53d1612bb483f88a8cf219"},
@@ -52,6 +52,7 @@
5252
"stream_data": {:hex, :stream_data, "1.1.2", "05499eaec0443349ff877aaabc6e194e82bda6799b9ce6aaa1aadac15a9fdb4d", [:mix], [], "hexpm", "129558d2c77cbc1eb2f4747acbbea79e181a5da51108457000020a906813a1a9"},
5353
"telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"},
5454
"text_diff": {:hex, :text_diff, "0.1.0", "1caf3175e11a53a9a139bc9339bd607c47b9e376b073d4571c031913317fecaa", [:mix], [], "hexpm", "d1ffaaecab338e49357b6daa82e435f877e0649041ace7755583a0ea3362dbd7"},
55+
"tz": {:hex, :tz, "0.28.1", "717f5ffddfd1e475e2a233e221dc0b4b76c35c4b3650b060c8e3ba29dd6632e9", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:mint, "~> 1.6", [hex: :mint, repo: "hexpm", optional: true]}], "hexpm", "bfdca1aa1902643c6c43b77c1fb0cb3d744fd2f09a8a98405468afdee0848c8a"},
5556
"yamerl": {:hex, :yamerl, "0.10.0", "4ff81fee2f1f6a46f1700c0d880b24d193ddb74bd14ef42cb0bcf46e81ef2f8e", [:rebar3], [], "hexpm", "346adb2963f1051dc837a2364e4acf6eb7d80097c0f53cbdc3046ec8ec4b4e6e"},
5657
"yaml_elixir": {:hex, :yaml_elixir, "2.11.0", "9e9ccd134e861c66b84825a3542a1c22ba33f338d82c07282f4f1f52d847bd50", [:mix], [{:yamerl, "~> 0.10", [hex: :yamerl, repo: "hexpm", optional: false]}], "hexpm", "53cc28357ee7eb952344995787f4bb8cc3cecbf189652236e9b163e8ce1bc242"},
5758
}

Diff for: test/calculation_test.exs

+5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ defmodule AshPostgres.CalculationTest do
4444
|> Ash.read!()
4545
end
4646

47+
test "start_of_day functions the same as Elixir's start of ay" do
48+
assert Ash.calculate!(Post, :start_of_day) ==
49+
Ash.Expr.eval!(Ash.Expr.expr(start_of_day(^DateTime.utc_now(), "EST")))
50+
end
51+
4752
@tag :regression
4853
test "an expression calculation that requires a left join & distinct doesn't raise errors on out of order params" do
4954
post =

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

+2
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ defmodule AshPostgres.Test.Post do
750750
)
751751
)
752752

753+
calculate(:start_of_day, :datetime, expr(start_of_day(fragment("now()::timestamp"), "EST")))
754+
753755
calculate(:author_count_of_posts, :integer, expr(author.count_of_posts_with_calc))
754756

755757
calculate(

0 commit comments

Comments
 (0)