Sha256: c0977eaceb23ceb759aa2481612b8af832b12da19882cdce8241fa0088826854

Contents?: true

Size: 1.36 KB

Versions: 5

Compression:

Stored size: 1.36 KB

Contents

require 'test/helper'

describe "Runpuppet::Agent" do
  before do
    @agent = TestContext.agent
  end

  describe :check_status do
    it "returns the action for puppet and branch" do
      @agent.stubs(:get).returns('run-master')
      @agent.check_status.must_equal ["run", "master"]
    end
  end

  describe :base_url do
    it 'works' do
      @agent.base_url('/action').must_equal "http://user:pass@puppet.example.com/action"
    end
  end

  describe "URL manipulation" do
    before do
      TestContext.config.stubs(:local_ip).returns('10.10.10.10')
      TestContext.config.stubs(:hostname).returns('example-vm')
    end


    describe :append_params_to_post do
      it  "adds hostname and local ip to params" do
        params = {}
        new_params = @agent.append_params_to_post(params)
        new_params[:hostname].must_equal 'example-vm'
        new_params[:ip].must_equal '10.10.10.10'
      end
    end

    describe :append_params_to_url do
      it "adds ip and hostname to url" do
        new_url = @agent.append_params_to_url('/action')
        new_url.must_equal "/action?hostname=example-vm&ip=10.10.10.10"
      end

      it "appends to existing params, if needed" do
        new_url = @agent.append_params_to_url('/action?some_funny_param=1')
        new_url.must_equal "/action?some_funny_param=1&hostname=example-vm&ip=10.10.10.10"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
runpuppet-1.0.0 test/agent_test.rb
runpuppet-1.0.0.rc6 test/agent_test.rb
runpuppet-1.0.0.rc5 test/agent_test.rb
runpuppet-1.0.0.rc4 test/agent_test.rb
runpuppet-1.0.0.rc2 test/agent_test.rb