File: digest_spec.rb

package info (click to toggle)
puppet 5.5.22-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 21,316 kB
  • sloc: ruby: 254,925; sh: 1,608; xml: 219; makefile: 153; sql: 103
file content (30 lines) | stat: -rw-r--r-- 755 bytes parent folder | download
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
require 'spec_helper'

describe "the digest function", :uses_checksums => true do
  before :all do
    Puppet::Parser::Functions.autoloader.loadall
  end

  before :each do
    n = Puppet::Node.new('unnamed')
    c = Puppet::Parser::Compiler.new(n)
    @scope = Puppet::Parser::Scope.new(c)
  end

  it "should exist" do
    expect(Puppet::Parser::Functions.function("digest")).to eq("function_digest")
  end

  with_digest_algorithms do
    it "should use the proper digest function" do
      result = @scope.function_digest([plaintext])
      expect(result).to(eql( checksum ))
    end

    it "should only accept one parameter" do
      expect do
        @scope.function_digest(['foo', 'bar'])
      end.to raise_error(ArgumentError)
    end
  end
end