Separated broken tests into new test file with trivial fix - WIP
This commit is contained in:
parent
9bd5b8aa68
commit
dcd5add809
4 changed files with 30 additions and 52 deletions
|
@ -1,7 +1,4 @@
|
|||
module Riemann::Dash::BrowserConfig
|
||||
require 'multi_json'
|
||||
require 'fileutils'
|
||||
require 'pp'
|
||||
|
||||
def self.backend
|
||||
@backend
|
||||
|
|
29
test/browser_config_test.rb
Normal file
29
test/browser_config_test.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
require './test/test_helper'
|
||||
|
||||
describe "Riemann::Dash::BrowserConfig" do
|
||||
|
||||
before do
|
||||
@mock_backend = Minitest::Mock.new
|
||||
Riemann::Dash::BrowserConfig.backend = @mock_backend
|
||||
end
|
||||
|
||||
describe :read do
|
||||
it "delegates to its backend" do
|
||||
@mock_backend.expect :read, :return_value
|
||||
|
||||
Riemann::Dash::BrowserConfig.read
|
||||
|
||||
@mock_backend.verify
|
||||
end
|
||||
end
|
||||
|
||||
describe :update do
|
||||
it "delegates to its backend" do
|
||||
@mock_backend.expect :update, :return_value, [String]
|
||||
|
||||
Riemann::Dash::BrowserConfig.update("stuff to update")
|
||||
|
||||
@mock_backend.verify
|
||||
end
|
||||
end
|
||||
end
|
|
@ -62,53 +62,4 @@ describe "Riemann::Dash::Config" do
|
|||
end
|
||||
end
|
||||
|
||||
describe "workspace config" do
|
||||
before do
|
||||
FileUtils.rm_rf "test/tmp/"
|
||||
end
|
||||
|
||||
|
||||
describe :read_ws_config do
|
||||
=begin
|
||||
# this test fails if the config living at config/config.json has
|
||||
# been overwritten with user content -- this happens for people
|
||||
# who had previously run their riemann-dash instance via simply
|
||||
# cd riemann-dash && bin/riemann-dash -- it would also fail once
|
||||
# you save your config in the default location
|
||||
it "retuns hash for empty configs" do
|
||||
@config.read_ws_config.must_equal "{}"
|
||||
end
|
||||
=end
|
||||
|
||||
it "reads the file, if present" do
|
||||
@config.load_config("test/fixtures/config/ws_config.rb").must_equal true
|
||||
@config.store[:ws_config].must_equal "test/fixtures/ws_config/dummy_config.json"
|
||||
@config.read_ws_config.must_equal %Q{{hey: \"ho\"}}
|
||||
end
|
||||
end
|
||||
|
||||
describe :update_ws_config do
|
||||
it "works" do
|
||||
@config.store[:ws_config] = "test/tmp/config.json"
|
||||
@config.update_ws_config("{\"server\":\"10.10.10.10\",\"workspaces\":[]}")
|
||||
end
|
||||
|
||||
it "pretty-prints the config" do
|
||||
@config.store[:ws_config] = "test/tmp/config.json"
|
||||
@config.update_ws_config("{\"server\":\"10.10.10.10\",\"workspaces\":[]}")
|
||||
File.read("test/tmp/config.json").must_equal File.read("test/fixtures/ws_config/pretty_printed_config.json")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "backwards compatible :[] and :[]= forwarders to `store` variable" do
|
||||
it "reading works" do
|
||||
@config[:ws_config].must_match %r{config/config.json}
|
||||
end
|
||||
|
||||
it "writing works" do
|
||||
@config[:ws_config] = "something"
|
||||
@config[:ws_config].must_match %r{something}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,6 +4,7 @@ Bundler.setup(:default, :test)
|
|||
|
||||
require 'minitest/autorun'
|
||||
require 'minitest/spec'
|
||||
require 'minitest/mock'
|
||||
#require "mocha/setup"
|
||||
|
||||
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
||||
|
|
Loading…
Reference in a new issue