Add puppet/archive module
[mirror/dsa-puppet.git] / 3rdparty / modules / archive / spec / unit / puppet / parser / functions / go_md5_spec.rb
diff --git a/3rdparty/modules/archive/spec/unit/puppet/parser/functions/go_md5_spec.rb b/3rdparty/modules/archive/spec/unit/puppet/parser/functions/go_md5_spec.rb
new file mode 100644 (file)
index 0000000..7dad352
--- /dev/null
@@ -0,0 +1,18 @@
+require 'spec_helper'
+
+describe :go_md5 do # rubocop:disable RSpec/DescribeSymbol
+  before :all do # rubocop:disable RSpec/BeforeAfterAll
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+
+  example_md5 = File.read(fixtures('checksum', 'gocd.md5'))
+
+  it 'retreives file md5' do
+    url = 'https://gocd.lan/path/file.md5'
+    uri = URI(url)
+    PuppetX::Bodeco::Util.stubs(:content).with(uri, username: 'user', password: 'pass').returns(example_md5)
+    expect(scope.function_go_md5(['user', 'pass', 'filea', url])).to eq '283158c7da8c0ada74502794fa8745eb'
+  end
+end