Skip to content

Commit

Permalink
Do not override existing CHEF_TELEMETRY_ENDPOINT env var if it is pre…
Browse files Browse the repository at this point in the history
…sent

Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
  • Loading branch information
marcparadise committed May 16, 2018
1 parent c2e307a commit af340d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/chef-cli/lib/chef-cli/telemeter/sender.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def run
if ChefCLI::Telemeter.enabled?
# dev mode telemetry gets sent to a different location
if ChefCLI::Config.telemetry.dev
ENV["CHEF_TELEMETRY_ENDPOINT"] = "https://telemetry-acceptance.chef.io"
ENV["CHEF_TELEMETRY_ENDPOINT"] ||= "https://telemetry-acceptance.chef.io"
end
session_files.each { |path| process_session(path) }
else
Expand Down
18 changes: 15 additions & 3 deletions components/chef-cli/spec/unit/telemeter/sender_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,21 @@
context "and telemetry dev mode is true" do
let(:dev_mode) { true }
let(:session_files) { [] } # Ensure we don't send anything without mocking :allthecalls:
it "configures the environment to submit to the Acceptance telemetry endpoint" do
subject.run
expect(ENV["CHEF_TELEMETRY_ENDPOINT"]).to eq "https://telemetry-acceptance.chef.io"
context "and a custom telemetry endpoint is not set" do
it "configures the environment to submit to the Acceptance telemetry endpoint" do
subject.run
expect(ENV["CHEF_TELEMETRY_ENDPOINT"]).to eq "https://telemetry-acceptance.chef.io"
end
end

context "and a custom telemetry endpoint is already set" do
before do
ENV["CHEF_TELEMETRY_ENDPOINT"] = "https://localhost"
end
it "should not overwrite the custom value" do
subject.run
expect(ENV["CHEF_TELEMETRY_ENDPOINT"]).to eq "https://localhost"
end
end
end

Expand Down

0 comments on commit af340d8

Please sign in to comment.