Skip to content

Commit

Permalink
fixed tests #114
Browse files Browse the repository at this point in the history
Signed-off-by: quobix <dave@quobix.com>
  • Loading branch information
daveshanley committed Mar 24, 2024
1 parent acdc0a5 commit 8470f90
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion git/read_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"os"
"os/exec"
"path"
"path/filepath"
"strings"
)

Expand Down Expand Up @@ -103,7 +104,7 @@ func PopulateHistoryWithChanges(commitHistory []*model.Commit, limit int,
progressChan chan *model.ProgressUpdate, errorChan chan model.ProgressError, base string, remote bool) ([]*model.Commit, []error) {

for c := range commitHistory {
cmd := exec.Command(GIT, NOPAGER, SHOW, fmt.Sprintf("%s:%s", commitHistory[c].Hash, commitHistory[c].FilePath))
cmd := exec.Command(GIT, NOPAGER, SHOW, fmt.Sprintf("%s:%s", commitHistory[c].Hash, filepath.Join(commitHistory[c].RepoDirectory, commitHistory[c].FilePath)))
var ou, er bytes.Buffer
cmd.Stdout = &ou
cmd.Stderr = &er
Expand Down
8 changes: 5 additions & 3 deletions git/read_local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@ func TestExtractHistoryFromFile(t *testing.T) {
d := make(chan bool)
go func() {
iterations := 0
for iterations < 23 {
for iterations < 26 {
select {
case <-c:

iterations++
case <-e:

iterations++
}
}
d <- true
}()

history, _ := ExtractHistoryFromFile("./", "read_local.go", c, e)
history, _ := ExtractHistoryFromFile("./", "read_local.go", c, e, 25)
<-d
assert.NotNil(t, history)
assert.Equal(t, "adding read_local.go to test repo code", history[len(history)-1].Message)
Expand All @@ -52,7 +54,7 @@ func TestExtractHistoryFromFile_Fail(t *testing.T) {
}
}()

history, _ := ExtractHistoryFromFile("./", "no_file_nope", c, e)
history, _ := ExtractHistoryFromFile("./", "no_file_nope", c, e, 5)
<-d
assert.Len(t, history, 0)
}
Expand Down

0 comments on commit 8470f90

Please sign in to comment.