Class: MCollective::Test::LocalAgentTest
- Inherits:
-
Object
- Object
- MCollective::Test::LocalAgentTest
- Includes:
- Util
- Defined in:
- lib/mcollective/test/local_agent_test.rb
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#connector ⇒ Object
readonly
Returns the value of attribute connector.
-
#facts ⇒ Object
readonly
Returns the value of attribute facts.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#plugin ⇒ Object
readonly
Returns the value of attribute plugin.
Instance Method Summary collapse
-
#initialize(agent, options = {}) ⇒ LocalAgentTest
constructor
A new instance of LocalAgentTest.
-
#make_call_helper ⇒ Object
Place the mocked connector into the plugin instance and create a call helper method that passes the connector in and call the action via handlemsg.
Methods included from Util
#create_config_mock, #create_connector_mock, #create_facts_mock, #create_logger_mock, #create_response, #load_agent, #load_application, #mock_validators
Constructor Details
#initialize(agent, options = {}) ⇒ LocalAgentTest
Returns a new instance of LocalAgentTest.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/mcollective/test/local_agent_test.rb', line 8 def initialize(agent, ={}) config = [:config] facts = [:facts] || {"fact" => "value"} @config = create_config_mock(config) @agent = agent.to_s @logger = create_logger_mock @connector = create_connector_mock @plugin = load_agent(agent, [:agent_file]) create_facts_mock(facts) mock_validators make_call_helper end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
4 5 6 |
# File 'lib/mcollective/test/local_agent_test.rb', line 4 def agent @agent end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/mcollective/test/local_agent_test.rb', line 4 def config @config end |
#connector ⇒ Object (readonly)
Returns the value of attribute connector.
4 5 6 |
# File 'lib/mcollective/test/local_agent_test.rb', line 4 def connector @connector end |
#facts ⇒ Object (readonly)
Returns the value of attribute facts.
4 5 6 |
# File 'lib/mcollective/test/local_agent_test.rb', line 4 def facts @facts end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
4 5 6 |
# File 'lib/mcollective/test/local_agent_test.rb', line 4 def logger @logger end |
#plugin ⇒ Object (readonly)
Returns the value of attribute plugin.
4 5 6 |
# File 'lib/mcollective/test/local_agent_test.rb', line 4 def plugin @plugin end |
Instance Method Details
#make_call_helper ⇒ Object
Place the mocked connector into the plugin instance and create a call helper method that passes the connector in and call the action via handlemsg.
This will let you test auditing etc
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/mcollective/test/local_agent_test.rb', line 31 def make_call_helper @plugin.instance_variable_set("@mocked_connector", @connector) @plugin.instance_eval " def call(action, args={}) request = {:action => action.to_s, :agent => '#{@agent}', :data => args} handlemsg({:body => request}, @mocked_connector) end " end |