# File test/test_entity.rb, line 7 def setup super @app_args = { "author" => "Harry Belten", "label" => "A random app", "description" => "Sumer is icumen in", } @entity = @service.apps.create(temporary_name(), @app_args) end
# File test/test_entity.rb, line 17 def teardown @entity.delete() if @service.splunk_version[0..1] != [4,2] clear_restart_message(@service) end super end
# File test/test_entity.rb, line 79 def test_disable_enable # We have to refresh first, because apps on some versions of Splunk # do not have all their keys (including "disabled") when first created. @entity.refresh() assert_equal('0', @entity["disabled"]) @entity.disable() @entity.refresh() assert_equal('1', @entity["disabled"]) @entity.enable() @entity.refresh() assert_equal('0', @entity["disabled"]) end
# File test/test_entity.rb, line 27 def test_fetch @app_args.each() do |key, value| assert_equal(value, @entity[key]) assert_equal(value, @entity.fetch(key)) end end
# File test/test_entity.rb, line 34 def test_fetch_with_default assert_equal("boris", @entity.fetch("nonexistant key", "boris")) end
# File test/test_entity.rb, line 50 def test_read state = @entity.read() assert_false(state.empty?) state.each() do |key, value| assert_equal(value, @entity[key]) end state.each() do |key, value| state[key] = "boris" assert_not_equal("boris", value) assert_equal(value, @entity[key]) end end
# File test/test_entity.rb, line 63 def test_state_with_field_list state = @entity.read("label", "description") assert_false(state.empty?) state.each() do |key, value| assert_equal(value, @entity[key]) end state.each() do |key, value| state[key] = "boris" assert_not_equal("boris", value) assert_equal(value, @entity[key]) end assert_equal(@entity.read("label", "description"), @entity.read(["label", "description"])) end
# File test/test_entity.rb, line 38 def test_update_and_refresh @entity.update("label" => "This is a test") assert_equal(@app_args["label"], @entity["label"]) @entity.refresh() assert_equal("This is a test", @entity["label"]) @entity["label"] = "Oh the vogonity!" assert_equal("This is a test", @entity["label"]) @entity.refresh() assert_equal("Oh the vogonity!", @entity["label"]) end