diff --git a/priv/repo/migrations/20240724180729_create_hydration_cache.exs b/priv/repo/migrations/20240724180729_create_hydration_cache.exs index af66ee53..51df9f6a 100644 --- a/priv/repo/migrations/20240724180729_create_hydration_cache.exs +++ b/priv/repo/migrations/20240724180729_create_hydration_cache.exs @@ -10,6 +10,9 @@ defmodule DpulCollections.Repo.Migrations.CreateHydrationCache do timestamps(updated_at: :cache_order, inserted_at: false, type: :utc_datetime) end - create unique_index(:hydration_cache, [:record_id, :cache_version], name: :record_id_cache_version_idx) + + create unique_index(:hydration_cache, [:record_id, :cache_version], + name: :record_id_cache_version_idx + ) end end diff --git a/test/dpul_collections/indexing_pipeline_test.exs b/test/dpul_collections/indexing_pipeline_test.exs index 6df4802a..1e98043f 100644 --- a/test/dpul_collections/indexing_pipeline_test.exs +++ b/test/dpul_collections/indexing_pipeline_test.exs @@ -8,7 +8,13 @@ defmodule DpulCollections.IndexingPipelineTest do import DpulCollections.IndexingPipelineFixtures - @invalid_attrs %{data: nil, cache_order: nil, cache_version: nil, record_id: nil, source_cache_order: nil} + @invalid_attrs %{ + data: nil, + cache_order: nil, + cache_version: nil, + record_id: nil, + source_cache_order: nil + } test "list_hydration_cache/0 returns all hydration_cache" do hydration_cache = hydration_cache_fixture() @@ -21,9 +27,17 @@ defmodule DpulCollections.IndexingPipelineTest do end test "create_hydration_cache/1 with valid data creates a hydration_cache" do - valid_attrs = %{data: "some data", cache_order: ~U[2024-07-23 18:07:00Z], cache_version: 42, record_id: "some record_id", source_cache_order: ~U[2024-07-23 18:07:00Z]} + valid_attrs = %{ + data: "some data", + cache_order: ~U[2024-07-23 18:07:00Z], + cache_version: 42, + record_id: "some record_id", + source_cache_order: ~U[2024-07-23 18:07:00Z] + } + + assert {:ok, %HydrationCache{} = hydration_cache} = + IndexingPipeline.create_hydration_cache(valid_attrs) - assert {:ok, %HydrationCache{} = hydration_cache} = IndexingPipeline.create_hydration_cache(valid_attrs) assert hydration_cache.data == "some data" assert hydration_cache.cache_order == ~U[2024-07-23 18:07:00Z] assert hydration_cache.cache_version == 42 @@ -37,9 +51,18 @@ defmodule DpulCollections.IndexingPipelineTest do test "update_hydration_cache/2 with valid data updates the hydration_cache" do hydration_cache = hydration_cache_fixture() - update_attrs = %{data: "some updated data", cache_order: ~U[2024-07-24 18:07:00Z], cache_version: 43, record_id: "some updated record_id", source_cache_order: ~U[2024-07-24 18:07:00Z]} - assert {:ok, %HydrationCache{} = hydration_cache} = IndexingPipeline.update_hydration_cache(hydration_cache, update_attrs) + update_attrs = %{ + data: "some updated data", + cache_order: ~U[2024-07-24 18:07:00Z], + cache_version: 43, + record_id: "some updated record_id", + source_cache_order: ~U[2024-07-24 18:07:00Z] + } + + assert {:ok, %HydrationCache{} = hydration_cache} = + IndexingPipeline.update_hydration_cache(hydration_cache, update_attrs) + assert hydration_cache.data == "some updated data" assert hydration_cache.cache_order == ~U[2024-07-24 18:07:00Z] assert hydration_cache.cache_version == 43 @@ -49,14 +72,20 @@ defmodule DpulCollections.IndexingPipelineTest do test "update_hydration_cache/2 with invalid data returns error changeset" do hydration_cache = hydration_cache_fixture() - assert {:error, %Ecto.Changeset{}} = IndexingPipeline.update_hydration_cache(hydration_cache, @invalid_attrs) + + assert {:error, %Ecto.Changeset{}} = + IndexingPipeline.update_hydration_cache(hydration_cache, @invalid_attrs) + assert hydration_cache == IndexingPipeline.get_hydration_cache!(hydration_cache.id) end test "delete_hydration_cache/1 deletes the hydration_cache" do hydration_cache = hydration_cache_fixture() assert {:ok, %HydrationCache{}} = IndexingPipeline.delete_hydration_cache(hydration_cache) - assert_raise Ecto.NoResultsError, fn -> IndexingPipeline.get_hydration_cache!(hydration_cache.id) end + + assert_raise Ecto.NoResultsError, fn -> + IndexingPipeline.get_hydration_cache!(hydration_cache.id) + end end test "change_hydration_cache/1 returns a hydration_cache changeset" do