summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2017-10-04 10:15:41 -0700
committerTim Smith <tsmith@chef.io>2018-02-26 12:22:02 -0800
commit35a3a95499c2541fb88566f0452b899718071cf7 (patch)
tree4dff7215f0b22a7423cfafaeba3b90f4f516d9a2
parent60bfd8be787e1d8d85ac214cf7f49eb0e6e5e06d (diff)
downloadchef-35a3a95499c2541fb88566f0452b899718071cf7.tar.gz
Test is_ppa_url and repo_components
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--spec/unit/provider/apt_repository_spec.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/unit/provider/apt_repository_spec.rb b/spec/unit/provider/apt_repository_spec.rb
index ac9ec79640..3dee0d518f 100644
--- a/spec/unit/provider/apt_repository_spec.rb
+++ b/spec/unit/provider/apt_repository_spec.rb
@@ -157,6 +157,35 @@ C5986B4F1257FFA86632CBA746181433FBB75451
end
end
+ describe "#is_ppa_url" do
+ it "returns true if the URL starts with ppa:" do
+ expect(provider.is_ppa_url?("ppa://example.com")).to be_truthy
+ end
+
+ it "returns false if the URL does not start with ppa:" do
+ expect(provider.is_ppa_url?("example.com")).to be_falsey
+ end
+ end
+
+ describe "#repo_components" do
+ it "returns 'main' if a PPA and components property not set" do
+ expect(provider).to receive(:is_ppa_url?).and_return(true)
+ expect(provider).repo_components.to eq('main')
+ end
+
+ it "returns components property if a PPA and components is set" do
+ new_resource.components('foo')
+ expect(provider).to receive(:is_ppa_url?).and_return(true)
+ expect(provider).repo_components.to eq('foo')
+ end
+
+ it "returns components property if not a PPA" do
+ new_resource.components('foo')
+ expect(provider).to receive(:is_ppa_url?).and_return(false)
+ expect(provider).repo_components.to eq('foo')
+ end
+ end
+
describe "#install_ppa_key" do
let(:url) { "https://launchpad.net/api/1.0/~chef/+archive/main" }
let(:key) { "C5986B4F1257FFA86632CBA746181433FBB75451" }