Skip to content

Commit 8f5701d

Browse files
committed
function: fix commit_stats_test
Signed-off-by: Javi Fontan <[email protected]>
1 parent 2914027 commit 8f5701d

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

integration_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ func TestIntegration(t *testing.T) {
5252
lib.AddLocation(loc)
5353

5454
pool := gitbase.NewRepositoryPool(cache.DefaultMaxSize, lib)
55-
// require.NoError(t, pool.AddGitWithID("worktree", path))
56-
57-
// lib, pool, err := test.NewMultiPool()
58-
// require.NoError(err)
59-
// require.NoError(t, lib.AddPlain("worktree", path, 0))
60-
6155
engine := newBaseEngine(pool)
6256

6357
testCases := []struct {

internal/function/commit_stats_test.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ package function
22

33
import (
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

Comments
 (0)