Skip to content

Commit

Permalink
Mix format.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpendragon committed Jul 24, 2024
1 parent 88cc357 commit 28ed2ee
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
43 changes: 36 additions & 7 deletions test/dpul_collections/indexing_pipeline_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 28ed2ee

Please sign in to comment.