Skip to content

Commit

Permalink
test: test new start_of_day logic from ash core
Browse files Browse the repository at this point in the history
this test won't pass until ash is updated
  • Loading branch information
zachdaniel committed Jan 30, 2025
1 parent ac3d0fa commit 6e29a4d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ if Mix.env() == :dev do
end

if Mix.env() == :test do
config :elixir, :time_zone_database, Tz.TimeZoneDatabase
config :ash_postgres, AshPostgres.TestRepo, log: false
config :ash_postgres, AshPostgres.TestNoSandboxRepo, log: false

Expand Down
1 change: 1 addition & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ defmodule AshPostgres.MixProject do
{:jason, "~> 1.0"},
{:postgrex, ">= 0.0.0"},
# dev/test dependencies
{:tz, "~> 0.28.1"},
{:ecto_dev_logger, "~> 0.14", only: :test},
{:eflame, "~> 1.0", only: [:dev, :test]},
{:simple_sat, "~> 0.1", only: [:dev, :test]},
Expand Down
3 changes: 2 additions & 1 deletion mix.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%{
"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"},
"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"},
"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"},
"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"},
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
"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"},
Expand Down Expand Up @@ -52,6 +52,7 @@
"stream_data": {:hex, :stream_data, "1.1.2", "05499eaec0443349ff877aaabc6e194e82bda6799b9ce6aaa1aadac15a9fdb4d", [:mix], [], "hexpm", "129558d2c77cbc1eb2f4747acbbea79e181a5da51108457000020a906813a1a9"},
"telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"},
"text_diff": {:hex, :text_diff, "0.1.0", "1caf3175e11a53a9a139bc9339bd607c47b9e376b073d4571c031913317fecaa", [:mix], [], "hexpm", "d1ffaaecab338e49357b6daa82e435f877e0649041ace7755583a0ea3362dbd7"},
"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"},
"yamerl": {:hex, :yamerl, "0.10.0", "4ff81fee2f1f6a46f1700c0d880b24d193ddb74bd14ef42cb0bcf46e81ef2f8e", [:rebar3], [], "hexpm", "346adb2963f1051dc837a2364e4acf6eb7d80097c0f53cbdc3046ec8ec4b4e6e"},
"yaml_elixir": {:hex, :yaml_elixir, "2.11.0", "9e9ccd134e861c66b84825a3542a1c22ba33f338d82c07282f4f1f52d847bd50", [:mix], [{:yamerl, "~> 0.10", [hex: :yamerl, repo: "hexpm", optional: false]}], "hexpm", "53cc28357ee7eb952344995787f4bb8cc3cecbf189652236e9b163e8ce1bc242"},
}
5 changes: 5 additions & 0 deletions test/calculation_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ defmodule AshPostgres.CalculationTest do
|> Ash.read!()
end

test "start_of_day functions the same as Elixir's start of ay" do

Check failure on line 47 in test/calculation_test.exs

View workflow job for this annotation

GitHub Actions / ash-ci (14) / mix test

test start_of_day functions the same as Elixir's start of ay (AshPostgres.CalculationTest)

Check failure on line 47 in test/calculation_test.exs

View workflow job for this annotation

GitHub Actions / ash-ci (15) / mix test

test start_of_day functions the same as Elixir's start of ay (AshPostgres.CalculationTest)

Check failure on line 47 in test/calculation_test.exs

View workflow job for this annotation

GitHub Actions / ash-ci (16) / mix test

test start_of_day functions the same as Elixir's start of ay (AshPostgres.CalculationTest)
assert Ash.calculate!(Post, :start_of_day) ==
Ash.Expr.eval!(Ash.Expr.expr(start_of_day(^DateTime.utc_now(), "EST")))
end

@tag :regression
test "an expression calculation that requires a left join & distinct doesn't raise errors on out of order params" do
post =
Expand Down
2 changes: 2 additions & 0 deletions test/support/resources/post.ex
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ defmodule AshPostgres.Test.Post do
)
)

calculate(:start_of_day, :datetime, expr(start_of_day(fragment("now()::timestamp"), "EST")))

calculate(:author_count_of_posts, :integer, expr(author.count_of_posts_with_calc))

calculate(
Expand Down

0 comments on commit 6e29a4d

Please sign in to comment.