Skip to content

Commit b684bfb

Browse files
committed
update code file view test
1 parent e210f5e commit b684bfb

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tests/code_file_view_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
package tests
22

33
import (
4-
"github.com/go-git/go-git/v5"
4+
"os"
5+
"path"
6+
"testing"
7+
8+
git "github.com/libgit2/git2go/v31"
59
"github.com/neel1996/gitconvex-server/api"
610
"github.com/neel1996/gitconvex-server/graph/model"
7-
"testing"
811
)
912

1013
func TestCodeFileView(t *testing.T) {
11-
r, _ := git.PlainOpen("..")
12-
w, _ := r.Worktree()
13-
repoPath := w.Filesystem.Root()
14+
cwd, _ := os.Getwd()
15+
r, _ := git.OpenRepository(path.Join(cwd, ".."))
16+
17+
repoPath := r.Path()
1418
expectedLine := "# gitconvex GoLang project"
1519

1620
type args struct {
@@ -27,7 +31,7 @@ func TestCodeFileView(t *testing.T) {
2731
repo *git.Repository
2832
repoPath string
2933
fileName string
30-
}{repo: r, repoPath: repoPath, fileName: "README.md"}, want: &model.CodeFileType{FileData: []*string{&expectedLine}}},
34+
}{repo: r, repoPath: path.Join(repoPath, ".."), fileName: "README.md"}, want: &model.CodeFileType{FileData: []*string{&expectedLine}}},
3135
}
3236
for _, tt := range tests {
3337
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)