@@ -25,9 +25,8 @@ type WorktreeSuite struct {
2525var _ = Suite (& WorktreeSuite {})
2626
2727func (s * WorktreeSuite ) SetUpTest (c * C ) {
28- s .buildBasicRepository (c )
29- // the index is removed if not the Repository will be not clean
30- c .Assert (s .Repository .Storer .SetIndex (& index.Index {Version : 2 }), IsNil )
28+ f := fixtures .Basic ().One ()
29+ s .Repository = s .NewRepositoryWithEmptyWorktree (f )
3130}
3231
3332func (s * WorktreeSuite ) TestCheckout (c * C ) {
@@ -87,13 +86,9 @@ func (s *WorktreeSuite) TestCheckoutSymlink(c *C) {
8786
8887func (s * WorktreeSuite ) TestCheckoutSubmodule (c * C ) {
8988 url := "https://github.com/git-fixtures/submodule.git"
90- w := & Worktree {
91- r : s .NewRepository (fixtures .ByURL (url ).One ()),
92- fs : memfs .New (),
93- }
89+ r := s .NewRepositoryWithEmptyWorktree (fixtures .ByURL (url ).One ())
9490
95- // we delete the index, since the fixture comes with a real index
96- err := w .r .Storer .SetIndex (& index.Index {Version : 2 })
91+ w , err := r .Worktree ()
9792 c .Assert (err , IsNil )
9893
9994 err = w .Checkout (& CheckoutOptions {})
@@ -106,16 +101,11 @@ func (s *WorktreeSuite) TestCheckoutSubmodule(c *C) {
106101
107102func (s * WorktreeSuite ) TestCheckoutSubmoduleInitialized (c * C ) {
108103 url := "https://github.com/git-fixtures/submodule.git"
109- w := & Worktree {
110- r : s .NewRepository (fixtures .ByURL (url ).One ()),
111- fs : memfs .New (),
112- }
104+ r := s .NewRepository (fixtures .ByURL (url ).One ())
113105
114- err := w . r . Storer . SetIndex ( & index. Index { Version : 2 } )
106+ w , err := r . Worktree ( )
115107 c .Assert (err , IsNil )
116108
117- err = w .Checkout (& CheckoutOptions {})
118- c .Assert (err , IsNil )
119109 sub , err := w .Submodules ()
120110 c .Assert (err , IsNil )
121111
@@ -228,15 +218,8 @@ func (s *WorktreeSuite) TestCheckoutChange(c *C) {
228218
229219func (s * WorktreeSuite ) TestCheckoutTag (c * C ) {
230220 f := fixtures .ByTag ("tags" ).One ()
231-
232- fs := memfs .New ()
233- w := & Worktree {
234- r : s .NewRepository (f ),
235- fs : fs ,
236- }
237-
238- // we delete the index, since the fixture comes with a real index
239- err := w .r .Storer .SetIndex (& index.Index {Version : 2 })
221+ r := s .NewRepositoryWithEmptyWorktree (f )
222+ w , err := r .Worktree ()
240223 c .Assert (err , IsNil )
241224
242225 err = w .Checkout (& CheckoutOptions {})
@@ -282,14 +265,9 @@ func (s *WorktreeSuite) TestCheckoutBisectSubmodules(c *C) {
282265// checking every commit over the previous commit
283266func (s * WorktreeSuite ) testCheckoutBisect (c * C , url string ) {
284267 f := fixtures .ByURL (url ).One ()
268+ r := s .NewRepositoryWithEmptyWorktree (f )
285269
286- w := & Worktree {
287- r : s .NewRepository (f ),
288- fs : memfs .New (),
289- }
290-
291- // we delete the index, since the fixture comes with a real index
292- err := w .r .Storer .SetIndex (& index.Index {Version : 2 })
270+ w , err := r .Worktree ()
293271 c .Assert (err , IsNil )
294272
295273 iter , err := w .r .Log (& LogOptions {})
0 commit comments