@@ -25,9 +25,8 @@ type WorktreeSuite struct {
25
25
var _ = Suite (& WorktreeSuite {})
26
26
27
27
func (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 )
31
30
}
32
31
33
32
func (s * WorktreeSuite ) TestCheckout (c * C ) {
@@ -87,13 +86,9 @@ func (s *WorktreeSuite) TestCheckoutSymlink(c *C) {
87
86
88
87
func (s * WorktreeSuite ) TestCheckoutSubmodule (c * C ) {
89
88
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 ())
94
90
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 ()
97
92
c .Assert (err , IsNil )
98
93
99
94
err = w .Checkout (& CheckoutOptions {})
@@ -106,16 +101,11 @@ func (s *WorktreeSuite) TestCheckoutSubmodule(c *C) {
106
101
107
102
func (s * WorktreeSuite ) TestCheckoutSubmoduleInitialized (c * C ) {
108
103
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 ())
113
105
114
- err := w . r . Storer . SetIndex ( & index. Index { Version : 2 } )
106
+ w , err := r . Worktree ( )
115
107
c .Assert (err , IsNil )
116
108
117
- err = w .Checkout (& CheckoutOptions {})
118
- c .Assert (err , IsNil )
119
109
sub , err := w .Submodules ()
120
110
c .Assert (err , IsNil )
121
111
@@ -228,15 +218,8 @@ func (s *WorktreeSuite) TestCheckoutChange(c *C) {
228
218
229
219
func (s * WorktreeSuite ) TestCheckoutTag (c * C ) {
230
220
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 ()
240
223
c .Assert (err , IsNil )
241
224
242
225
err = w .Checkout (& CheckoutOptions {})
@@ -282,14 +265,9 @@ func (s *WorktreeSuite) TestCheckoutBisectSubmodules(c *C) {
282
265
// checking every commit over the previous commit
283
266
func (s * WorktreeSuite ) testCheckoutBisect (c * C , url string ) {
284
267
f := fixtures .ByURL (url ).One ()
268
+ r := s .NewRepositoryWithEmptyWorktree (f )
285
269
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 ()
293
271
c .Assert (err , IsNil )
294
272
295
273
iter , err := w .r .Log (& LogOptions {})
0 commit comments