analytics: stop sending analytics in tests

This commit is contained in:
Sean Molenaar 2023-02-06 16:28:34 +01:00
parent bdc22fe0c7
commit 10e3c522f7
No known key found for this signature in database
GPG Key ID: AAC1C7E1A4696A9A
2 changed files with 8 additions and 4 deletions

View File

@ -117,9 +117,8 @@ describe Utils::Analytics do
ENV.delete("HOMEBREW_NO_ANALYTICS")
ENV["HOMEBREW_ANALYTICS_DEBUG"] = "true"
ENV["HOMEBREW_ANALYTICS_ENABLE_INFLUX"] = "true"
expect do
described_class.report_influx(:install, action, true, developer: true, CI: true)
end.to output(/--data-raw install,[a-zA-Z=,]*,action=formula_name\\ --head/).to_stdout
expect(described_class).to receive(:defered_curl).once
described_class.report_influx(:install, action, true, developer: true, CI: true)
end
end

View File

@ -99,8 +99,13 @@ module Utils
"--data-raw", "#{category},#{tags} count=1i #{Time.now.to_i}"
]
curl = Utils::Curl.curl_executable
url = "https://#{INFLUX_HOST}/api/v2/write?bucket=#{INFLUX_BUCKET}&precision=s"
defered_curl(url, args)
end
sig { params(url: String, args: T::Array[String]).void }
def defered_curl(url, args)
curl = Utils::Curl.curl_executable
if ENV["HOMEBREW_ANALYTICS_DEBUG"]
puts "#{curl} #{args.join(" ")} \"#{url}\""
puts Utils.popen_read(curl, *args, url)