File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,8 +42,9 @@ def start
4242
4343 def run_review ( argv )
4444 options , mr_url = review_options_and_url ( argv )
45+ parser_result = MrParser . parse ( mr_url )
4546 config = load_review_config ( options )
46- context = load_review_context ( mr_url , config , options )
47+ context = load_review_context ( parser_result , config , options )
4748
4849 execute_review ( config , context , options )
4950 end
@@ -72,8 +73,7 @@ def load_review_config(options)
7273 config
7374 end
7475
75- def load_review_context ( mr_url , config , options )
76- parser_result = MrParser . parse ( mr_url )
76+ def load_review_context ( parser_result , config , options )
7777 gitlab_client = build_gitlab_client ( config , parser_result )
7878 merge_request , changes = fetch_merge_request_data ( gitlab_client , parser_result )
7979
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ require 'stringio'
4+ require 'aireview'
5+
6+ RSpec . describe Aireview ::CLI do
7+ describe '.start' do
8+ it 'rejects an invalid URL before loading config' do
9+ error_output = StringIO . new
10+
11+ expect ( Aireview ::Config ) . not_to receive ( :load )
12+
13+ status = described_class . start (
14+ [ 'review' , 'gitlab.company.com/team/project/-/merge_requests/123' ] ,
15+ out : StringIO . new ,
16+ err : error_output
17+ )
18+
19+ expect ( status ) . to eq ( 1 )
20+ expect ( error_output . string ) . to include ( 'Merge request URL must include http:// or https://' )
21+ end
22+ end
23+ end
You can’t perform that action at this time.
0 commit comments