appcast: remove calculate_checkpoint

This commit is contained in:
commitay 2018-06-09 08:45:13 +10:00
parent dbeed9e583
commit c3ac638b9f
2 changed files with 0 additions and 64 deletions

View File

@ -11,24 +11,6 @@ module Hbc
@checkpoint = parameters[:checkpoint]
end
def calculate_checkpoint
curl_executable, *args = curl_args(
"--compressed", "--location", "--fail", uri,
user_agent: :fake
)
result = SystemCommand.run(curl_executable, args: args, print_stderr: false)
checkpoint = if result.success?
processed_appcast_text = result.stdout.gsub(%r{<pubDate>[^<]*</pubDate>}m, "")
Digest::SHA2.hexdigest(processed_appcast_text)
end
{
checkpoint: checkpoint,
command_result: result,
}
end
def to_yaml
[uri, parameters].to_yaml
end

View File

@ -30,50 +30,4 @@ describe Hbc::DSL::Appcast do
end
end
end
describe "#calculate_checkpoint" do
before do
expect(Hbc::SystemCommand).to receive(:run) do |executable, **options|
expect(executable).to eq "/usr/bin/curl"
expect(options[:args]).to include(*cmd_args)
expect(options[:print_stderr]).to be false
cmd_result
end
allow(cmd_result).to receive(:success?).and_return(cmd_success)
allow(cmd_result).to receive(:stdout).and_return(cmd_stdout)
end
context "when server returns a successful HTTP status" do
let(:cmd_args) { [HOMEBREW_USER_AGENT_FAKE_SAFARI, "--compressed", "--location", "--fail", uri] }
let(:cmd_result) { double("Hbc::SystemCommand::Result") }
let(:cmd_success) { true }
let(:cmd_stdout) { "hello world" }
it "generates the content digest hash and returns a hash with the command result and the digest hash for the checkpoint" do
expected_digest = Digest::SHA2.hexdigest(cmd_stdout)
expected_result = {
checkpoint: expected_digest,
command_result: cmd_result,
}
expect(subject.calculate_checkpoint).to eq(expected_result)
end
end
context "when server returns a non-successful HTTP status" do
let(:cmd_args) { [HOMEBREW_USER_AGENT_FAKE_SAFARI, "--compressed", "--location", "--fail", uri] }
let(:cmd_result) { double("Hbc::SystemCommand::Result") }
let(:cmd_success) { false }
let(:cmd_stdout) { "some error message from the server" }
it "returns a hash with the command result and nil for the checkpoint" do
expected_result = {
checkpoint: nil,
command_result: cmd_result,
}
expect(subject.calculate_checkpoint).to eq(expected_result)
end
end
end
end