File tree Expand file tree Collapse file tree
lib/octocatalog-diff/catalog-util
spec/octocatalog-diff/tests/catalog-util Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ def self.git_checkout(logger, dir_opts)
101101 logger . debug ( "Begin git checkout #{ dir_opts [ :basedir ] } :#{ dir_opts [ :branch ] } -> #{ dir_opts [ :path ] } " )
102102 OctocatalogDiff ::CatalogUtil ::Git . check_out_git_archive ( dir_opts . merge ( logger : logger ) )
103103 logger . debug ( "Success git checkout #{ dir_opts [ :basedir ] } :#{ dir_opts [ :branch ] } -> #{ dir_opts [ :path ] } " )
104- rescue OctocatalogDiff ::CatalogUtil :: Git ::GitCheckoutError => exc
104+ rescue OctocatalogDiff ::Errors ::GitCheckoutError => exc
105105 logger . error ( "Git checkout error: #{ exc } " )
106106 raise OctocatalogDiff ::Errors ::BootstrapError , exc
107107 end
Original file line number Diff line number Diff line change 164164 end
165165 end
166166 end
167+
168+ describe '#git_checkout' do
169+ context 'with successful git checkout' do
170+ it 'should log success messages' do
171+ expect ( OctocatalogDiff ::CatalogUtil ::Git ) . to receive ( :check_out_git_archive )
172+ logger , logger_str = OctocatalogDiff ::Spec . setup_logger
173+ opts = { basedir : '/tmp/foo' , branch : 'foo' , path : '/tmp/bar' }
174+ described_class . git_checkout ( logger , opts )
175+ expect ( logger_str . string ) . to match ( %r{Begin git checkout /tmp/foo:foo -> /tmp/bar} )
176+ expect ( logger_str . string ) . to match ( %r{Success git checkout /tmp/foo:foo -> /tmp/bar} )
177+ end
178+ end
179+
180+ context 'with failed git checkout' do
181+ it 'should log error messages and raise OctocatalogDiff::Errors::BootstrapError' do
182+ expect ( OctocatalogDiff ::CatalogUtil ::Git ) . to receive ( :check_out_git_archive )
183+ . and_raise ( OctocatalogDiff ::Errors ::GitCheckoutError , 'Oopsie' )
184+ logger , logger_str = OctocatalogDiff ::Spec . setup_logger
185+ opts = { basedir : '/tmp/foo' , branch : 'foo' , path : '/tmp/bar' }
186+ expect { described_class . git_checkout ( logger , opts ) } . to raise_error ( OctocatalogDiff ::Errors ::BootstrapError )
187+ expect ( logger_str . string ) . to match ( %r{Begin git checkout /tmp/foo:foo -> /tmp/bar} )
188+ expect ( logger_str . string ) . to match ( /Git checkout error: Oopsie/ )
189+ end
190+ end
191+ end
167192end
You can’t perform that action at this time.
0 commit comments