blob: c94f3e47ed17d642923552dd64f363c6e2e4f7f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#!/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::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
|