-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample_test.exs
51 lines (41 loc) · 1.14 KB
/
example_test.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
defmodule ExampleTest do
use ExUnit.Case
require Approvals
defmodule Item do
defstruct name: nil, sell_in: nil, quality: nil
end
defmodule GuildedRose do
def update_quality(data), do: data
end
# begin-snippet: guilded_rose_example
# If you want to set up special output file names you can define the parts here
# otherwise they default to the test file name.
# def config do
# %Approvals{
# project_name: "approval_tests",
# test_name: "example_test",
# file_extension: "txt",
# file_path: "test"
# }
# end
test "Example approvals test" do
input_builder = fn %{name: name, sell_in: sell_in, quality: quality} ->
%Item{name: name, sell_in: sell_in, quality: quality}
end
test_data =
[
name: [
"Others",
"Aged Brie",
"Backstage passes to a TAFKAL80ETC concert",
"Sulfuras, Hand of Ragnaros"
],
sell_in: [-1, 0, 1, 10, 50],
quality: [0, 1, 49, 50]
]
|> Approvals.gen_test_data_set(input_builder)
GuildedRose.update_quality(test_data)
|> Approvals.verify()
end
# end-snippet
end