Skip to content

Commit

Permalink
Add empty map integration specs
Browse files Browse the repository at this point in the history
  • Loading branch information
merqlove committed Feb 11, 2017
1 parent b247110 commit 04853cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/mongo_ecto/normalized_query_new_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ defmodule Mongo.Ecto.NormalizedQueryNewTest do
defmodule Schema4 do
use Ecto.Schema

schema "schema3" do
schema "schema4" do
field :map1, :map, default: %{}
field :binary, :binary
end
Expand Down
12 changes: 12 additions & 0 deletions test/mongo_ecto_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ defmodule Mongo.EctoTest do
assert [%{"ints" => [1]}] = TestRepo.all(query)
end

test "retrieve empty map" do
TestRepo.insert!(%Post{meta: %{}})

assert nil != TestRepo.get_by(Post, meta: %{})
end

test "retrieve non empty map" do
TestRepo.insert!(%Post{meta: %{a: 5}})

assert %{"a" => 5} == TestRepo.get_by(Post, meta: %{a: 5}).meta
end

test "count" do
TestRepo.insert!(%Post{visits: 1})

Expand Down

0 comments on commit 04853cb

Please sign in to comment.