2018-02-13 15:35:45 +00:00
|
|
|
describe QA::Git::Location do
|
2018-02-13 16:59:38 +00:00
|
|
|
describe '.new' do
|
2018-02-12 08:43:32 +00:00
|
|
|
context 'when URI starts with ssh://' do
|
|
|
|
context 'when URI has port' do
|
|
|
|
it 'parses correctly' do
|
|
|
|
uri = described_class
|
2018-02-13 16:59:38 +00:00
|
|
|
.new('ssh://git@qa.test:2222/sandbox/qa/repo.git')
|
2018-02-12 08:43:32 +00:00
|
|
|
|
|
|
|
expect(uri.user).to eq('git')
|
|
|
|
expect(uri.host).to eq('qa.test')
|
|
|
|
expect(uri.port).to eq(2222)
|
|
|
|
expect(uri.path).to eq('/sandbox/qa/repo.git')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when URI does not have port' do
|
|
|
|
it 'parses correctly' do
|
|
|
|
uri = described_class
|
2018-02-13 16:59:38 +00:00
|
|
|
.new('ssh://git@qa.test/sandbox/qa/repo.git')
|
2018-02-12 08:43:32 +00:00
|
|
|
|
|
|
|
expect(uri.user).to eq('git')
|
|
|
|
expect(uri.host).to eq('qa.test')
|
2018-02-12 15:25:18 +00:00
|
|
|
expect(uri.port).to eq(22)
|
2018-02-12 08:43:32 +00:00
|
|
|
expect(uri.path).to eq('/sandbox/qa/repo.git')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when URI does not start with ssh://' do
|
|
|
|
context 'when host does not have colons' do
|
|
|
|
it 'parses correctly' do
|
|
|
|
uri = described_class
|
2018-02-13 16:59:38 +00:00
|
|
|
.new('git@qa.test:sandbox/qa/repo.git')
|
2018-02-12 08:43:32 +00:00
|
|
|
|
|
|
|
expect(uri.user).to eq('git')
|
|
|
|
expect(uri.host).to eq('qa.test')
|
2018-02-12 15:25:18 +00:00
|
|
|
expect(uri.port).to eq(22)
|
2018-02-12 08:43:32 +00:00
|
|
|
expect(uri.path).to eq('/sandbox/qa/repo.git')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when host has a colon' do
|
|
|
|
it 'parses correctly' do
|
|
|
|
uri = described_class
|
2018-02-13 16:59:38 +00:00
|
|
|
.new('[git@qa:test]:sandbox/qa/repo.git')
|
2018-02-12 08:43:32 +00:00
|
|
|
|
|
|
|
expect(uri.user).to eq('git')
|
|
|
|
expect(uri.host).to eq('qa%3Atest')
|
2018-02-12 15:25:18 +00:00
|
|
|
expect(uri.port).to eq(22)
|
2018-02-12 08:43:32 +00:00
|
|
|
expect(uri.path).to eq('/sandbox/qa/repo.git')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|