@@ -2,14 +2,18 @@ package function
22
33import (
44 "context"
5+ "os"
6+ "path/filepath"
57 "testing"
68
79 "github.com/src-d/gitbase"
810 "github.com/src-d/gitbase/internal/commitstats"
11+ "github.com/src-d/go-borges/plain"
912 "github.com/stretchr/testify/require"
1013
1114 "github.com/src-d/go-mysql-server/sql"
1215 "github.com/src-d/go-mysql-server/sql/expression"
16+ "gopkg.in/src-d/go-billy.v4/osfs"
1317 fixtures "gopkg.in/src-d/go-git-fixtures.v3"
1418 "gopkg.in/src-d/go-git.v4/plumbing/cache"
1519)
@@ -21,9 +25,24 @@ func TestCommitStatsEval(t *testing.T) {
2125 }()
2226
2327 path := fixtures .ByTag ("worktree" ).One ().Worktree ().Root ()
28+ pathLib := path + "-lib"
29+ pathRepo := filepath .Join (pathLib , "worktree" )
2430
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 )
2746
2847 session := gitbase .NewSession (pool )
2948 ctx := sql .NewContext (context .TODO (), sql .WithSession (session ))
0 commit comments