Skip to content

Commit

Permalink
Demonstrate Dataloader.KV not making subsequent loads
Browse files Browse the repository at this point in the history
Add a Dataloader.KV test to assert that the loader can
load new data in subsequent rounds.

See issue #74
  • Loading branch information
alex-knowles committed Apr 12, 2019
1 parent e9e8e8d commit ef5c978
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/dataloader/kv_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ defmodule Dataloader.KVTest do
assert loader != round1_loader
end

test "loading something not in the cache does change the loader", %{loader: loader} do
round1_loader =
loader
|> Dataloader.load(Test, :users, "ben")
|> Dataloader.run()

round2_loader =
round1_loader
|> Dataloader.load(Test, :users, "bruce")
|> Dataloader.run()

refute round2_loader == round1_loader
refute loader == round1_loader
end

test "cache can be warmed", %{loader: loader} do
loader = Dataloader.put(loader, Test, :users, "ben", @data[:users] |> List.first())

Expand Down

0 comments on commit ef5c978

Please sign in to comment.