Add puppet/archive module, required for newer puppet/rabbitmq
[mirror/dsa-puppet.git] / 3rdparty / modules / archive / spec / unit / puppet / parser / functions / artifactory_sha1_spec.rb
diff --git a/3rdparty/modules/archive/spec/unit/puppet/parser/functions/artifactory_sha1_spec.rb b/3rdparty/modules/archive/spec/unit/puppet/parser/functions/artifactory_sha1_spec.rb
new file mode 100644 (file)
index 0000000..13a7782
--- /dev/null
@@ -0,0 +1,18 @@
+require 'spec_helper'
+
+describe :artifactory_sha1 do # rubocop:disable RSpec/DescribeSymbol
+  before :all do # rubocop:disable RSpec/BeforeAfterAll
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+
+  example_json = File.read(fixtures('checksum', 'artifactory.json'))
+
+  it 'parses sha1' do
+    url = 'https://repo.jfrog.org/artifactory/api/storage/distributions/images/Artifactory_120x75.png'
+    uri = URI(url)
+    PuppetX::Bodeco::Util.stubs(:content).with(uri).returns(example_json)
+    expect(scope.function_artifactory_sha1([url])).to eq 'a359e93636e81f9dd844b2dfb4b89fa876e5d4fa'
+  end
+end