Skip to content

Commit d7789de

Browse files
committed
chore: add test for decimal numbers
1 parent 1104b42 commit d7789de

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/collections/simple_test.exs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ defmodule Collections.SimpleTest do
1818
collection "tasks" do
1919
attribute :name, String.t(), default: "Fix errors"
2020
attribute :status, integer(), derived: true
21+
attribute :sequence_id, BSON.Decimal128.t(), default: Decimal.new(0)
2122
after_load &Task.after_load/1
2223
end
2324

@@ -116,6 +117,17 @@ defmodule Collections.SimpleTest do
116117
assert %Card{intro: "new intro", label: %Label{color: :red, name: "warning"}} = struct_card
117118
end
118119

120+
test "dump decimal attributes", c do
121+
alias Collections.SimpleTest.Task
122+
123+
task = %Task{Task.new() | sequence_id: Decimal.new(123)}
124+
assert :ok = Task.insert_one(task, c.pid)
125+
126+
task = Task.find_one(task._id, c.pid)
127+
assert task.sequence_id != Decimal.new(0)
128+
assert task.sequence_id == Decimal.new(123)
129+
end
130+
119131
test "dump derived attributes", c do
120132
alias Collections.SimpleTest.Task
121133
task = %Task{Task.new() | status: :red}

0 commit comments

Comments
 (0)