Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin <sachin.jain@chef.io>
  • Loading branch information
Sachin committed Oct 30, 2024
1 parent 5c0f5d1 commit e251ba9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions spec/unit/policyfile/artifactory_cookbook_source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,27 @@
end
end

describe "#ARTIFACTORY_IDENTITY_KEY" do
describe "#artifactory_identity_key" do
before do
ENV["ARTIFACTORY_IDENTITY_KEY"] = "test"
end

context "when config is not present" do
let(:config) { nil }
it "should get artifactory key from the env" do
expect(subject.ARTIFACTORY_IDENTITY_KEY).to eq("test")
expect(subject.artifactory_identity_key).to eq("test")
end
end

context "when config is present" do
let(:config) { double("Chef::Config") }
it "should get artifactory key from config when key is present" do
expect(config).to receive(:ARTIFACTORY_IDENTITY_KEY).and_return "test1"
expect(subject.ARTIFACTORY_IDENTITY_KEY).to eq("test1")
expect(config).to receive(:artifactory_identity_key).and_return "test1"
expect(subject.artifactory_identity_key).to eq("test1")
end
it "should get artifactory key from env when config is present but has a nil key" do
expect(config).to receive(:ARTIFACTORY_IDENTITY_KEY).and_return nil
expect(subject.ARTIFACTORY_IDENTITY_KEY).to eq("test")
expect(config).to receive(:artifactory_identity_key).and_return nil
expect(subject.artifactory_identity_key).to eq("test")
end
end
end
Expand Down

0 comments on commit e251ba9

Please sign in to comment.