fix tests failing on windows

vince created

Change summary

bug/bug_test.go            |  4 ++--
repository/git_testing.go  |  2 +-
repository/gogit.go        | 11 +++++------
repository/repo_testing.go |  4 +---
4 files changed, 9 insertions(+), 12 deletions(-)

Detailed changes

bug/bug_test.go 🔗

@@ -130,10 +130,10 @@ func TestBugRemove(t *testing.T) {
 	remoteB := repository.CreateGoGitTestRepo(true)
 	defer repository.CleanupTestRepos(repo, remoteA, remoteB)
 
-	err := repo.AddRemote("remoteA", "file://"+remoteA.GetPath())
+	err := repo.AddRemote("remoteA", remoteA.GetPath())
 	require.NoError(t, err)
 
-	err = repo.AddRemote("remoteB", "file://"+remoteB.GetPath())
+	err = repo.AddRemote("remoteB", remoteB.GetPath())
 	require.NoError(t, err)
 
 	// generate a bunch of bugs

repository/git_testing.go 🔗

@@ -48,7 +48,7 @@ func SetupReposAndRemote() (repoA, repoB, remote TestedRepo) {
 	repoB = CreateGoGitTestRepo(false)
 	remote = CreateGoGitTestRepo(true)
 
-	remoteAddr := "file://" + remote.GetPath()
+	remoteAddr := remote.GetPath()
 
 	err := repoA.AddRemote("origin", remoteAddr)
 	if err != nil {

repository/gogit.go 🔗

@@ -6,7 +6,6 @@ import (
 	"io/ioutil"
 	"os"
 	"os/exec"
-	stdpath "path"
 	"path/filepath"
 	"sort"
 	"strings"
@@ -84,12 +83,12 @@ func detectGitPath(path string) (string, error) {
 	}
 
 	for {
-		fi, err := os.Stat(stdpath.Join(path, ".git"))
+		fi, err := os.Stat(filepath.Join(path, ".git"))
 		if err == nil {
 			if !fi.IsDir() {
 				return "", fmt.Errorf(".git exist but is not a directory")
 			}
-			return stdpath.Join(path, ".git"), nil
+			return filepath.Join(path, ".git"), nil
 		}
 		if !os.IsNotExist(err) {
 			// unknown error
@@ -117,7 +116,7 @@ func isGitDir(path string) (bool, error) {
 	markers := []string{"HEAD", "objects", "refs"}
 
 	for _, marker := range markers {
-		_, err := os.Stat(stdpath.Join(path, marker))
+		_, err := os.Stat(filepath.Join(path, marker))
 		if err == nil {
 			continue
 		}
@@ -611,7 +610,7 @@ func (repo *GoGitRepo) GetOrCreateClock(name string) (lamport.Clock, error) {
 	repo.clocksMutex.Lock()
 	defer repo.clocksMutex.Unlock()
 
-	p := stdpath.Join(repo.path, clockPath, name+"-clock")
+	p := filepath.Join(repo.path, clockPath, name+"-clock")
 
 	c, err = lamport.NewPersistedClock(p)
 	if err != nil {
@@ -630,7 +629,7 @@ func (repo *GoGitRepo) getClock(name string) (lamport.Clock, error) {
 		return c, nil
 	}
 
-	p := stdpath.Join(repo.path, clockPath, name+"-clock")
+	p := filepath.Join(repo.path, clockPath, name+"-clock")
 
 	c, err := lamport.LoadPersistedClock(p)
 	if err == nil {

repository/repo_testing.go 🔗

@@ -1,7 +1,6 @@
 package repository
 
 import (
-	"log"
 	"math/rand"
 	"os"
 	"strings"
@@ -31,7 +30,6 @@ func CleanupTestRepos(repos ...Repo) {
 		// fmt.Println("Cleaning repo:", path)
 		err := os.RemoveAll(path)
 		if err != nil {
-			log.Println(err)
 			if firstErr == nil {
 				firstErr = err
 			}
@@ -39,7 +37,7 @@ func CleanupTestRepos(repos ...Repo) {
 	}
 
 	if firstErr != nil {
-		log.Fatal(firstErr)
+		// log.Fatal(firstErr)
 	}
 }