diff options
author | Tim Smith <tsmith@chef.io> | 2017-10-04 09:41:41 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-02-26 12:22:02 -0800 |
commit | 7257e5ef2ada0b4a8fd7ec8f73c2970de874b3e3 (patch) | |
tree | 87aa8e4bda5bca5a9f64fd9698c73e2e4b62054e /spec | |
parent | 57caf8292d44b43d9e46e409c96ab3eb800f0c38 (diff) | |
download | chef-7257e5ef2ada0b4a8fd7ec8f73c2970de874b3e3.tar.gz |
Test cookbook_name and key_type methods
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/provider/apt_repository_spec.rb | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/spec/unit/provider/apt_repository_spec.rb b/spec/unit/provider/apt_repository_spec.rb index cabf6551c9..a08c78a49e 100644 --- a/spec/unit/provider/apt_repository_spec.rb +++ b/spec/unit/provider/apt_repository_spec.rb @@ -112,6 +112,13 @@ C5986B4F1257FFA86632CBA746181433FBB75451 end end + describe "#cookbook_name" do + it "returns 'test' when the cookbook property is set" do + new_resource.cookbook("test") + expect(provider.cookbook_name).to eq("test") + end + end + describe "#no_new_keys?" do before do allow(provider).to receive(:extract_fingerprints_from_cmd).with(apt_key_finger_cmd).and_return(apt_fingerprints) @@ -134,6 +141,22 @@ C5986B4F1257FFA86632CBA746181433FBB75451 end end + describe "#key_type" do + it "returns :remote_file with an http URL" do + expect(provider.key_type("https://www.chef.io/key")).to eq(:remote_file) + end + + it "returns :cookbook_file with a chef managed file" do + expect(provider).to receive(:has_cookbook_file?).and_return(true) + expect(provider.key_type("/foo/bar.key")).to eq(:cookbook_file) + end + + it "throws exception if an unknown file specified" do + expect(provider).to receive(:has_cookbook_file?).and_return(false) + expect { provider.key_type("/foo/bar.key") }.to raise_error(Chef::Exceptions::FileNotFound) + end + end + describe "#install_ppa_key" do let(:url) { "https://launchpad.net/api/1.0/~chef/+archive/main" } let(:key) { "C5986B4F1257FFA86632CBA746181433FBB75451" } @@ -185,5 +208,4 @@ C5986B4F1257FFA86632CBA746181433FBB75451 expect(provider.build_repo("ppa:chef/main", "unstable", "main", false, nil)).to eql(target) end end - end |