Happy case tests for index_by
This commit is contained in:
parent
d1b0485aef
commit
58df11e022
2 changed files with 17 additions and 2 deletions
|
@ -25,8 +25,6 @@ module Riemann::Dash::BrowserConfig
|
|||
backend.update(update)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# TODO: this is gonna take significant restructuring of the dashboard itself,
|
||||
# but we should move to http://arxiv.org/abs/1201.1784 or equivalent CRDTs.
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require './test/test_helper'
|
||||
require 'pp'
|
||||
|
||||
describe "Riemann::Dash::BrowserConfig" do
|
||||
|
||||
|
@ -61,4 +62,20 @@ describe "Riemann::Dash::BrowserConfig" do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe :index_by do
|
||||
before do
|
||||
@list = [{'name' => 'a'}, {'name' => 'b'}, {'name' => 'c'}]
|
||||
end
|
||||
|
||||
it "returns the list of key/value pairs as a map indexed by the specified key/value" do
|
||||
indexed_config = Riemann::Dash::BrowserConfig.index_by(lambda { |x| x['name'] }, @list)
|
||||
|
||||
assert_equal({'name' => 'a'}, indexed_config['a'])
|
||||
assert_equal({'name' => 'b'}, indexed_config['b'])
|
||||
assert_equal({'name' => 'c'}, indexed_config['c'])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue