diff options
author | Luke Kanies <luke@madstop.com> | 2007-09-22 20:00:15 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-09-22 20:00:15 -0500 |
commit | 84146d00eed4765e6dbe05dd8de9f4c3625463b7 (patch) | |
tree | 56bbe17f2c596478e646207f132dc3bce4d4d492 /spec/unit/other/checksum.rb | |
parent | 3a18348fdbea39f56857b03c8f531bd5a2a8105d (diff) | |
download | puppet-84146d00eed4765e6dbe05dd8de9f4c3625463b7.tar.gz puppet-84146d00eed4765e6dbe05dd8de9f4c3625463b7.tar.xz puppet-84146d00eed4765e6dbe05dd8de9f4c3625463b7.zip |
Adding the first version of checksum support, which will
acquire the behaviour of FileBuckets.
Diffstat (limited to 'spec/unit/other/checksum.rb')
-rwxr-xr-x | spec/unit/other/checksum.rb | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/spec/unit/other/checksum.rb b/spec/unit/other/checksum.rb new file mode 100755 index 000000000..5610870a6 --- /dev/null +++ b/spec/unit/other/checksum.rb @@ -0,0 +1,60 @@ +#!/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 do + it "should have 'Checksum' and the checksum algorithm when converted to a string" do + sum = Puppet::Checksum.new("whatever") + sum.algorithm = "yay" + sum.to_s.should == "Checksum<{yay}whatever>" + end + + it "should convert algorithm names to symbols when they are set after checksum creation" do + sum = Puppet::Checksum.new("whatever") + sum.algorithm = "yay" + sum.algorithm.should == :yay + end +end + +describe Puppet::Checksum, " when initializing" do + it "should require a name" do + proc { Puppet::Checksum.new(nil) }.should raise_error(ArgumentError) + end + + it "should set the name appropriately" do + Puppet::Checksum.new("whatever").name.should == "whatever" + end + + it "should parse checksum algorithms out of the name if they are there" do + sum = Puppet::Checksum.new("{other}whatever") + sum.algorithm.should == :other + sum.name.should == "whatever" + end + + it "should default to 'md5' as the checksum algorithm if the algorithm is not in the name" do + Puppet::Checksum.new("whatever").algorithm.should == :md5 + end +end + +describe Puppet::Checksum, " when using back-ends" do + it "should redirect using Puppet::Indirector" do + Puppet::Indirector::Indirection.instance(:checksum).model.should equal(Puppet::Checksum) + end + + it "should have a :save instance method" do + Puppet::Checksum.new("mysum").should respond_to(:save) + end + + it "should respond to :find" do + Puppet::Checksum.should respond_to(:find) + end + + it "should respond to :destroy" do + Puppet::Checksum.should respond_to(:destroy) + end +end |