Commit 79fd1cab8ff646c01f74bf144d1d28e3d66e5e3c
1 parent
895927fb
Exists in
master
and in
2 other branches
Added tests for return values [skip ci]
Showing
2 changed files
with
21 additions
and
6 deletions
Show diff stats
test/index_test.rb
... | ... | @@ -75,6 +75,18 @@ class IndexTest < Minitest::Test |
75 | 75 | Product.reindex |
76 | 76 | end |
77 | 77 | |
78 | + # keep simple for now, but maybe return client response in future | |
79 | + def test_store_response | |
80 | + product = Searchkick.callbacks(false) { Product.create!(name: "Product A") } | |
81 | + assert_nil Product.search_index.store(product) | |
82 | + end | |
83 | + | |
84 | + # keep simple for now, but maybe return client response in future | |
85 | + def test_bulk_index_response | |
86 | + product = Searchkick.callbacks(false) { Product.create!(name: "Product A") } | |
87 | + assert_nil Product.search_index.bulk_index([product]) | |
88 | + end | |
89 | + | |
78 | 90 | # TODO move |
79 | 91 | |
80 | 92 | def test_filterable | ... | ... |
test/reindex_test.rb
... | ... | @@ -5,7 +5,8 @@ class ReindexTest < Minitest::Test |
5 | 5 | store_names ["Product A", "Product B"], reindex: false |
6 | 6 | |
7 | 7 | product = Product.find_by!(name: "Product A") |
8 | - product.reindex(refresh: true) | |
8 | + # TODO decide on return value | |
9 | + assert_kind_of Object, product.reindex(refresh: true) | |
9 | 10 | assert_search "product", ["Product A"] |
10 | 11 | end |
11 | 12 | |
... | ... | @@ -15,14 +16,15 @@ class ReindexTest < Minitest::Test |
15 | 16 | product = Product.find_by!(name: "Product A") |
16 | 17 | product.destroy |
17 | 18 | Product.search_index.refresh |
18 | - product.reindex | |
19 | + assert_nil product.reindex | |
19 | 20 | end |
20 | 21 | |
21 | 22 | def test_record_async |
22 | 23 | store_names ["Product A", "Product B"], reindex: false |
23 | 24 | |
24 | 25 | product = Product.find_by!(name: "Product A") |
25 | - product.reindex(mode: :async) | |
26 | + # TODO decide on return value | |
27 | + assert_kind_of ActiveJob::Base, product.reindex(mode: :async) | |
26 | 28 | Product.search_index.refresh |
27 | 29 | assert_search "product", ["Product A"] |
28 | 30 | end |
... | ... | @@ -36,7 +38,8 @@ class ReindexTest < Minitest::Test |
36 | 38 | store_names ["Product A", "Product B"], reindex: false |
37 | 39 | |
38 | 40 | product = Product.find_by!(name: "Product A") |
39 | - product.reindex(mode: :queue) | |
41 | + # TODO improve return value | |
42 | + assert_equal 1, product.reindex(mode: :queue) | |
40 | 43 | Product.search_index.refresh |
41 | 44 | assert_search "product", [] |
42 | 45 | |
... | ... | @@ -56,7 +59,7 @@ class ReindexTest < Minitest::Test |
56 | 59 | store_names ["Product A"] |
57 | 60 | store = Store.create!(name: "Test") |
58 | 61 | Product.create!(name: "Product B", store_id: store.id) |
59 | - store.products.reindex(refresh: true) | |
62 | + assert_equal true, store.products.reindex(refresh: true) | |
60 | 63 | assert_search "product", ["Product A", "Product B"] |
61 | 64 | end |
62 | 65 | |
... | ... | @@ -65,7 +68,7 @@ class ReindexTest < Minitest::Test |
65 | 68 | Searchkick.callbacks(false) do |
66 | 69 | Product.find_by(name: "Product B").update!(name: "DO NOT INDEX") |
67 | 70 | end |
68 | - Product.where(name: "DO NOT INDEX").reindex | |
71 | + assert_equal true, Product.where(name: "DO NOT INDEX").reindex | |
69 | 72 | Product.search_index.refresh |
70 | 73 | assert_search "product", ["Product A"] |
71 | 74 | end | ... | ... |