Skip to content

Commit 1e74720

Browse files
committed
include proper repo paths to all test scripts
1 parent 0515f59 commit 1e74720

7 files changed

+18
-11
lines changed

tests/git_commit_changes_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
git2go "github.com/libgit2/git2go/v31"
66
git2 "github.com/neel1996/gitconvex-server/git"
7+
"github.com/stretchr/testify/assert"
78
"io/ioutil"
89
"os"
910
"path"
@@ -19,7 +20,8 @@ func TestCommitChanges(t *testing.T) {
1920
fmt.Println("Environment : " + currentEnv)
2021

2122
if currentEnv == "ci" {
22-
r, _ = git2go.OpenRepository(mockRepoPath)
23+
repoPath = mockRepoPath
24+
r, _ = git2go.OpenRepository(repoPath)
2325
}
2426

2527
sampleFile := "untracked.txt"
@@ -54,9 +56,8 @@ func TestCommitChanges(t *testing.T) {
5456
RepoPath: repoPath,
5557
}
5658

57-
if got := testObj.CommitChanges(); got != tt.want {
58-
t.Errorf("CommitChanges() = %v, want %v", got, tt.want)
59-
}
59+
got := testObj.CommitChanges()
60+
assert.Equal(t, tt.want, got)
6061
})
6162
}
6263
}

tests/git_commit_compare_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ func TestCompareCommit(t *testing.T) {
1919
fmt.Println("Environment : " + currentEnv)
2020

2121
if currentEnv == "ci" {
22-
r, _ = git.OpenRepository(mockRepoPath)
22+
repoPath = mockRepoPath
23+
r, _ = git.OpenRepository(repoPath)
2324
} else {
2425
repoPath = path.Join(cwd, "../..")
2526
r, _ = git.OpenRepository(repoPath)
@@ -43,7 +44,7 @@ func TestCompareCommit(t *testing.T) {
4344
repo *git.Repository
4445
baseCommitString string
4546
compareCommitString string
46-
}{repo: r, baseCommitString: *sampleCommits.Commits[0].Hash, compareCommitString: *sampleCommits.Commits[1].Hash}},
47+
}{repo: r, baseCommitString: *sampleCommits.Commits[1].Hash, compareCommitString: *sampleCommits.Commits[2].Hash}},
4748
}
4849
for _, tt := range tests {
4950
t.Run(tt.name, func(t *testing.T) {

tests/git_commit_files_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ func TestCommitFileList(t *testing.T) {
2020
fmt.Println("Environment : " + currentEnv)
2121

2222
if currentEnv == "ci" {
23-
r, _ = git.OpenRepository(mockRepoPath)
23+
repoPath = mockRepoPath
24+
r, _ = git.OpenRepository(repoPath)
2425
} else {
2526
repoPath = path.Join(cwd, "../..")
2627
r, _ = git.OpenRepository(repoPath)

tests/git_commit_log_search_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ func TestSearchCommitLogs(t *testing.T) {
1919
mockRepoPath := path.Join(cwd, "../..") + "/starfleet"
2020

2121
if currentEnv == "ci" {
22-
r, _ = git.OpenRepository(mockRepoPath)
22+
repoPath = mockRepoPath
23+
r, _ = git.OpenRepository(repoPath)
2324
} else {
2425
repoPath = path.Join(cwd, "../..")
2526
r, _ = git.OpenRepository(repoPath)

tests/git_commit_logs_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ func TestCommitLogs(t *testing.T) {
1919
mockRepoPath := path.Join(cwd, "../..") + "/starfleet"
2020

2121
if currentEnv == "ci" {
22-
r, _ = git.OpenRepository(mockRepoPath)
22+
repoPath = mockRepoPath
23+
r, _ = git.OpenRepository(repoPath)
2324
} else {
2425
repoPath = path.Join(cwd, "../..")
2526
r, _ = git.OpenRepository(repoPath)

tests/git_ls_files_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ func TestListFiles(t *testing.T) {
2020
fmt.Println("Environment : " + currentEnv)
2121

2222
if currentEnv == "ci" {
23-
r, _ = git.OpenRepository(mockRepoPath)
23+
repoPath = mockRepoPath
24+
r, _ = git.OpenRepository(repoPath)
2425
} else {
2526
repoPath = path.Join(cwd, "../..")
2627
r, _ = git.OpenRepository(repoPath)

tests/git_total_commits_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ func TestTotalCommitLogs(t *testing.T) {
2020
fmt.Println("Environment : " + currentEnv)
2121

2222
if currentEnv == "ci" {
23-
r, _ = git.OpenRepository(mockRepoPath)
23+
repoPath = mockRepoPath
24+
r, _ = git.OpenRepository(repoPath)
2425
} else {
2526
repoPath = path.Join(cwd, "../..")
2627
r, _ = git.OpenRepository(repoPath)

0 commit comments

Comments
 (0)