Sha256: f0f93f90ae522782fab7b33322a52205b71e6e08d30bd32692c9bf43e74384a4

Contents?: true

Size: 1.32 KB

Versions: 8

Compression:

Stored size: 1.32 KB

Contents

#!/usr/bin/env ruby
#
#  Created by Luke Kanies on 2007-9-22.
#  Copyright (c) 2007. All rights reserved.

require File.dirname(__FILE__) + '/../spec_helper'

require 'puppet/checksum'

describe Puppet::Checksum, " when using the file terminus" do
    before do
        Puppet.settings.stubs(:use)
        Puppet::Checksum.terminus_class = :file
        @content = "this is some content"
        @sum = Puppet::Checksum.new(@content)

        @file = Puppet::Checksum.indirection.terminus.path(@sum.checksum)
    end

    it "should store content at a path determined by its checksum" do
        File.stubs(:directory?).returns(true)
        filehandle = mock 'filehandle'
        filehandle.expects(:print).with(@content)
        File.expects(:open).with(@file, "w").yields(filehandle)

        @sum.save
    end

    it "should retrieve stored content when the checksum is provided as the key" do
        File.stubs(:exist?).returns(true)
        File.expects(:read).with(@file).returns(@content)

        newsum = Puppet::Checksum.find(@sum.checksum)

        newsum.content.should == @content
    end

    it "should remove specified files when asked" do
        File.stubs(:exist?).returns(true)
        File.expects(:unlink).with(@file)

        Puppet::Checksum.destroy(@sum.name)
    end

    after do
        Puppet.settings.clear
    end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
puppet-0.25.5 spec/integration/checksum.rb
puppet-0.25.4 spec/integration/checksum.rb
puppet-0.25.3 spec/integration/checksum.rb
puppet-0.24.9 spec/integration/checksum.rb
puppet-0.25.2 spec/integration/checksum.rb
puppet-0.25.1 spec/integration/checksum.rb
puppet-0.25.0 spec/integration/checksum.rb
puppet-0.24.8 spec/integration/checksum.rb