X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Funit%2Fplugins%2Fmcollective%2Fdata%2Fagent_data_spec.rb;fp=spec%2Funit%2Fplugins%2Fmcollective%2Fdata%2Fagent_data_spec.rb;h=8477a63f89ac71704f060b63563ec9eaeae59af3;hb=b87d2f4e68281062df1913440ca5753ae63314a9;hp=0000000000000000000000000000000000000000;hpb=ab0ea530b8ac956091f17b104ab2311336cfc250;p=packages%2Fprecise%2Fmcollective.git diff --git a/spec/unit/plugins/mcollective/data/agent_data_spec.rb b/spec/unit/plugins/mcollective/data/agent_data_spec.rb new file mode 100644 index 0000000..8477a63 --- /dev/null +++ b/spec/unit/plugins/mcollective/data/agent_data_spec.rb @@ -0,0 +1,43 @@ +#!/usr/bin/env rspec + +require 'spec_helper' + +require File.dirname(__FILE__) + "/../../../../../plugins/mcollective/data/agent_data.rb" + +module MCollective + module Data + describe Agent_data do + describe "#query_data" do + before do + @ddl = mock + @ddl.stubs(:meta).returns({:timeout => 1}) + DDL.stubs(:new).returns(@ddl) + @plugin = Agent_data.new + end + + it "should fail for unknown agents" do + expect { @plugin.query_data("rspec") }.to raise_error("No agent called rspec found") + end + + it "should retrieve the correct agent and data" do + agent = mock + agent.stubs(:meta).returns({:license => "license", + :timeout => "timeout", + :description => "description", + :url => "url", + :version => "version", + :author => "author"}) + + PluginManager.stubs(:[]).with("rspec_agent").returns(agent) + PluginManager.expects(:include?).with("rspec_agent").returns(true) + + @plugin.query_data("rspec") + + [:license, :timeout, :description, :url, :version, :author].each do |item| + @plugin.result[item].should == item.to_s + end + end + end + end + end +end