@@ -71,16 +71,6 @@ func TestConfigureControls(t *testing.T) {
7171 return i
7272 },
7373 },
74- {
75- name : "GetVcsBackend-fails" , mustErr : true ,
76- controls : []models.ControlConfiguration {models .CONFIG_BRANCH_RULES },
77- prepare : func (t * testing.T ) toolImplementation {
78- t .Helper ()
79- i := & sourcetoolfakes.FakeToolImplementation {}
80- i .GetVcsBackendReturns (nil , syntErr )
81- return i
82- },
83- },
8474 {
8575 name : "CheckPolicyFork-fails" , mustErr : true ,
8676 controls : []models.ControlConfiguration {models .CONFIG_POLICY },
@@ -291,50 +281,62 @@ func TestOnboardRepository(t *testing.T) {
291281 t .Parallel ()
292282 for _ , tt := range []struct {
293283 name string
294- getSut func (t * testing.T ) toolImplementation
284+ impl func (t * testing.T ) toolImplementation
285+ backend func (t * testing.T ) models.VcsBackend
295286 mustErr bool
296287 }{
297- {"normal" , func (t * testing.T ) toolImplementation {
298- t .Helper ()
299- timp := & sourcetoolfakes.FakeToolImplementation {}
300- timp .GetVcsBackendReturns (& modelsfakes.FakeVcsBackend {}, nil )
301- timp .VerifyOptionsForFullOnboardReturns (nil )
302- timp .ConfigureControlsReturns (nil )
303- return timp
304- }, false },
305- {"get-vcs-fails" , func (t * testing.T ) toolImplementation {
306- t .Helper ()
307- timp := & sourcetoolfakes.FakeToolImplementation {}
308- timp .GetVcsBackendReturns (nil , errors .New ("vcsborked" ))
309- timp .VerifyOptionsForFullOnboardReturns (nil )
310- timp .ConfigureControlsReturns (nil )
311- return timp
312- }, true },
313- {"get-verifyoptions-fails" , func (t * testing.T ) toolImplementation {
314- t .Helper ()
315- timp := & sourcetoolfakes.FakeToolImplementation {}
316- timp .GetVcsBackendReturns (& modelsfakes.FakeVcsBackend {}, nil )
317- timp .VerifyOptionsForFullOnboardReturns (errors .New ("onboarderr" ))
318- return timp
319- }, true },
320- {"backend-configure-controls-fails" , func (t * testing.T ) toolImplementation {
321- t .Helper ()
322- bend := modelsfakes.FakeVcsBackend {}
323- bend .ConfigureControlsReturns (errors .New ("configure-error" ))
324-
325- timp := & sourcetoolfakes.FakeToolImplementation {}
326- timp .GetVcsBackendReturns (& bend , nil )
327- timp .VerifyOptionsForFullOnboardReturns (nil )
328- return timp
329- }, true },
288+ {
289+ name : "normal" ,
290+ impl : func (t * testing.T ) toolImplementation {
291+ t .Helper ()
292+ timp := & sourcetoolfakes.FakeToolImplementation {}
293+ timp .VerifyOptionsForFullOnboardReturns (nil )
294+ return timp
295+ },
296+ backend : func (t * testing.T ) models.VcsBackend {
297+ t .Helper ()
298+ return & modelsfakes.FakeVcsBackend {}
299+ },
300+ mustErr : false ,
301+ },
302+ {
303+ name : "get-verifyoptions-fails" ,
304+ impl : func (t * testing.T ) toolImplementation {
305+ t .Helper ()
306+ timp := & sourcetoolfakes.FakeToolImplementation {}
307+ timp .VerifyOptionsForFullOnboardReturns (errors .New ("onboarderr" ))
308+ return timp
309+ },
310+ backend : func (t * testing.T ) models.VcsBackend {
311+ t .Helper ()
312+ return & modelsfakes.FakeVcsBackend {}
313+ },
314+ mustErr : true ,
315+ },
316+ {
317+ name : "backend-configure-controls-fails" ,
318+ impl : func (t * testing.T ) toolImplementation {
319+ t .Helper ()
320+ timp := & sourcetoolfakes.FakeToolImplementation {}
321+ timp .VerifyOptionsForFullOnboardReturns (nil )
322+ return timp
323+ },
324+ backend : func (t * testing.T ) models.VcsBackend {
325+ t .Helper ()
326+ bend := & modelsfakes.FakeVcsBackend {}
327+ bend .ConfigureControlsReturns (errors .New ("configure-error" ))
328+ return bend
329+ },
330+ mustErr : true ,
331+ },
330332 } {
331333 t .Run (tt .name , func (t * testing.T ) {
332334 t .Parallel ()
333- impl := tt . getSut ( t )
334- tool , err := New ()
335- require . NoError ( t , err )
336- tool . impl = impl
337- err = tool .OnboardRepository (t .Context (), & models.Repository {Path : "example/repo" }, []* models.Branch {{Name : "main" }})
335+ tool := & Tool {
336+ impl : tt . impl ( t ),
337+ backend : tt . backend ( t ),
338+ }
339+ err : = tool .OnboardRepository (t .Context (), & models.Repository {Path : "example/repo" }, []* models.Branch {{Name : "main" }})
338340 if tt .mustErr {
339341 require .Error (t , err )
340342 return
0 commit comments