@@ -2,14 +2,18 @@ package function
2
2
3
3
import (
4
4
"context"
5
+ "os"
6
+ "path/filepath"
5
7
"testing"
6
8
7
9
"github.com/src-d/gitbase"
8
10
"github.com/src-d/gitbase/internal/commitstats"
11
+ "github.com/src-d/go-borges/plain"
9
12
"github.com/stretchr/testify/require"
10
13
11
14
"github.com/src-d/go-mysql-server/sql"
12
15
"github.com/src-d/go-mysql-server/sql/expression"
16
+ "gopkg.in/src-d/go-billy.v4/osfs"
13
17
fixtures "gopkg.in/src-d/go-git-fixtures.v3"
14
18
"gopkg.in/src-d/go-git.v4/plumbing/cache"
15
19
)
@@ -21,9 +25,24 @@ func TestCommitStatsEval(t *testing.T) {
21
25
}()
22
26
23
27
path := fixtures .ByTag ("worktree" ).One ().Worktree ().Root ()
28
+ pathLib := path + "-lib"
29
+ pathRepo := filepath .Join (pathLib , "worktree" )
24
30
25
- pool := gitbase .NewRepositoryPool (cache .DefaultMaxSize )
26
- require .NoError (t , pool .AddGitWithID ("worktree" , path ))
31
+ err := os .MkdirAll (pathLib , 0777 )
32
+ require .NoError (t , err )
33
+ defer func () {
34
+ require .NoError (t , os .RemoveAll (pathLib ))
35
+ }()
36
+
37
+ err = os .Rename (path , pathRepo )
38
+ require .NoError (t , err )
39
+
40
+ lib := plain .NewLibrary ("plain" )
41
+ loc , err := plain .NewLocation ("location" , osfs .New (pathLib ), nil )
42
+ require .NoError (t , err )
43
+ lib .AddLocation (loc )
44
+
45
+ pool := gitbase .NewRepositoryPool (cache .DefaultMaxSize , lib )
27
46
28
47
session := gitbase .NewSession (pool )
29
48
ctx := sql .NewContext (context .TODO (), sql .WithSession (session ))
0 commit comments