Skip to content

Commit

Permalink
Merge pull request #3068 from robertcheramy/fix-rake-test
Browse files Browse the repository at this point in the history
Fix rake test
  • Loading branch information
robertcheramy authored Feb 15, 2024
2 parents 2142210 + 8624169 commit e80f5c8
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 23 deletions.
47 changes: 27 additions & 20 deletions spec/input/ssh_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
describe Oxidized::SSH do
before(:each) do
Oxidized.asetus = Asetus.new
Oxidized.asetus.cfg.debug = false
Oxidized.setup_logger
Oxidized.config.timeout = 30
Oxidized.config.input.ssh.secure = true
Expand Down Expand Up @@ -31,16 +32,19 @@

proxy = mock
Net::SSH::Proxy::Command.expects(:new).with("ssh test.com -W [%h]:%p").returns(proxy)
Net::SSH.expects(:start).with('93.184.216.34', 'alma', port: 22,
verify_host_key: Oxidized.config.input.ssh.secure ? :always : :never,
append_all_supported_algorithms: true,
keepalive: true,
forward_agent: false,
password: 'armud',
timeout: Oxidized.config.timeout,
number_of_password_prompts: 0,
auth_methods: %w[none publickey password],
proxy: proxy)
ssh_options = {
port: 22,
verify_host_key: Oxidized.config.input.ssh.secure ? :always : :never,
append_all_supported_algorithms: true,
keepalive: true,
forward_agent: false,
password: 'armud',
timeout: Oxidized.config.timeout,
number_of_password_prompts: 0,
auth_methods: %w[none publickey password],
proxy: proxy
}
Net::SSH.expects(:start).with('93.184.216.34', 'alma', ssh_options)

ssh.instance_variable_set("@exec", true)
ssh.connect(@node)
Expand All @@ -64,16 +68,19 @@

proxy = mock
Net::SSH::Proxy::Command.expects(:new).with("ssh test.com -W [%h]:%p").returns(proxy)
Net::SSH.expects(:start).with('example.com', 'alma', port: 22,
verify_host_key: Oxidized.config.input.ssh.secure ? :always : :never,
append_all_supported_algorithms: true,
keepalive: true,
forward_agent: false,
password: 'armud',
timeout: Oxidized.config.timeout,
number_of_password_prompts: 0,
auth_methods: %w[none publickey password],
proxy: proxy)
ssh_options = {
port: 22,
verify_host_key: Oxidized.config.input.ssh.secure ? :always : :never,
append_all_supported_algorithms: true,
keepalive: true,
forward_agent: false,
password: 'armud',
timeout: Oxidized.config.timeout,
number_of_password_prompts: 0,
auth_methods: %w[none publickey password],
proxy: proxy
}
Net::SSH.expects(:start).with('example.com', 'alma', ssh_options)

ssh.instance_variable_set("@exec", true)
ssh.connect(@node)
Expand Down
1 change: 1 addition & 0 deletions spec/node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
describe Oxidized::Node do
before(:each) do
Oxidized.asetus = Asetus.new
Oxidized.asetus.cfg.debug = false
Oxidized.setup_logger

Oxidized::Node.any_instance.stubs(:resolve_repo)
Expand Down
1 change: 1 addition & 0 deletions spec/nodes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
before(:each) do
Resolv.any_instance.stubs(:getaddress)
Oxidized.asetus = Asetus.new
Oxidized.asetus.cfg.debug = false
Oxidized.setup_logger

opts = {
Expand Down
4 changes: 3 additions & 1 deletion spec/refinements_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@

_(str2.instance_variable_get(:@cmd)).must_equal str1.instance_variable_get(:@cmd)
_(str2.instance_variable_get(:@name)).must_equal str1.instance_variable_get(:@name)
_(str2.instance_variable_get(:@type)).must_equal str1.instance_variable_get(:@type)
# :@type is always nil
_(str2.instance_variable_get(:@type)).must_be_nil
_(str1.instance_variable_get(:@type)).must_be_nil
end
end
end
4 changes: 2 additions & 2 deletions spec/source/http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
_(Oxidized::HTTP.new.send(:string_navigate, h1, "inventory[0].ip")).must_equal "10.10.10.10"
end
it "should return nil on non-existing string key" do
_(Oxidized::HTTP.new.send(:string_navigate, h1, "jotain.3")).must_equal nil
_(Oxidized::HTTP.new.send(:string_navigate, h1, "jotain.3")).must_be_nil
end
it "should return nil on non-existing array index" do
_(Oxidized::HTTP.new.send(:string_navigate, h1, "inventory[3]")).must_equal nil
_(Oxidized::HTTP.new.send(:string_navigate, h1, "inventory[3]")).must_be_nil
end
end
end

0 comments on commit e80f5c8

Please sign in to comment.