2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-07-27 01:52:21 +05:30
|
|
|
require "utils/svn"
|
|
|
|
|
|
|
|
describe Utils do
|
|
|
|
describe "#self.svn_available?" do
|
2018-03-25 13:30:37 +01:00
|
|
|
before do
|
2017-08-24 01:31:12 +05:30
|
|
|
described_class.clear_svn_version_cache
|
2017-07-27 04:18:43 +05:30
|
|
|
end
|
|
|
|
|
2017-07-27 04:40:27 +05:30
|
|
|
it "returns svn version if svn available" do
|
2020-06-24 10:14:04 +01:00
|
|
|
if quiet_system "#{HOMEBREW_SHIMS_PATH}/scm/svn", "--version"
|
2018-03-25 13:30:37 +01:00
|
|
|
expect(described_class).to be_svn_available
|
2017-09-25 17:21:11 -07:00
|
|
|
else
|
2018-03-25 13:30:37 +01:00
|
|
|
expect(described_class).not_to be_svn_available
|
2017-09-25 17:21:11 -07:00
|
|
|
end
|
2017-07-27 01:52:21 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-08-11 18:53:13 +01:00
|
|
|
describe "#self.svn_version" do
|
|
|
|
before do
|
|
|
|
described_class.clear_svn_version_cache
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns nil when svn is not available" do
|
|
|
|
allow(described_class).to receive(:svn_available?).and_return(false)
|
|
|
|
expect(described_class.svn_version).to eq(nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns version of svn when svn is available", :needs_svn do
|
|
|
|
expect(described_class.svn_version).not_to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-14 16:55:45 -05:00
|
|
|
describe "#self.svn_remote_exists?" do
|
2017-07-27 04:18:43 +05:30
|
|
|
it "returns true when svn is not available" do
|
2018-03-25 13:30:37 +01:00
|
|
|
allow(described_class).to receive(:svn_available?).and_return(false)
|
|
|
|
expect(described_class).to be_svn_remote_exists("blah")
|
2017-07-27 01:52:21 +05:30
|
|
|
end
|
|
|
|
|
2017-07-27 04:40:27 +05:30
|
|
|
context "when svn is available" do
|
|
|
|
before do
|
2018-03-25 13:30:37 +01:00
|
|
|
allow(described_class).to receive(:svn_available?).and_return(true)
|
2017-07-27 04:40:27 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it "returns false when remote does not exist" do
|
2018-03-25 13:30:37 +01:00
|
|
|
expect(described_class).not_to be_svn_remote_exists(HOMEBREW_CACHE/"install")
|
2017-07-27 04:40:27 +05:30
|
|
|
end
|
|
|
|
|
2018-02-05 18:36:26 -08:00
|
|
|
it "returns true when remote exists", :needs_network, :needs_svn do
|
2018-08-06 20:41:21 +02:00
|
|
|
HOMEBREW_CACHE.cd do
|
2018-09-02 13:43:58 +01:00
|
|
|
system HOMEBREW_SHIMS_PATH/"scm/svn", "checkout",
|
2019-04-30 08:44:35 +01:00
|
|
|
"--non-interactive", "--trust-server-cert", "--quiet",
|
|
|
|
"https://github.com/Homebrew/install"
|
2018-08-06 20:41:21 +02:00
|
|
|
end
|
2017-07-27 01:52:21 +05:30
|
|
|
|
2018-03-25 13:30:37 +01:00
|
|
|
expect(described_class).to be_svn_remote_exists(HOMEBREW_CACHE/"install")
|
2017-07-27 04:40:27 +05:30
|
|
|
end
|
2017-07-27 01:52:21 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|