Removed file git history (#128)

This commit is contained in:
Domas Monkus 2020-10-09 10:52:05 +03:00 committed by GitHub
parent 57f7843ae1
commit 5eb33f8675
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 171 additions and 44 deletions

View file

@ -3,8 +3,8 @@ package git_test
import (
"testing"
git "github.com/go-git/go-git/v5"
"github.com/stretchr/testify/assert"
git "gopkg.in/src-d/go-git.v4"
gitutil "github.com/mattermost/mattermost-plugin-starter-template/build/sync/plan/git"
)
@ -16,6 +16,7 @@ func TestFileHistory(t *testing.T) {
DetectDotGit: true,
})
assert.Nil(err)
sums, err := gitutil.FileHistory("build/sync/plan/git/testdata/testfile.txt", repo)
assert.Nil(err)
assert.Contains(sums, "ba7192052d7cf77c55d3b7bf40b350b8431b208b")
@ -24,4 +25,9 @@ func TestFileHistory(t *testing.T) {
sums, err = gitutil.FileHistory("build/sync/plan/git/testdata/nosuch_testfile.txt", repo)
assert.Equal(gitutil.ErrNotFound, err)
assert.Nil(sums)
// Calling with a non-existent file that was in git history returns no error.
sums, err = gitutil.FileHistory("build/sync/plan/git/testdata/removedfile.txt", repo)
assert.Nil(err)
assert.Equal([]string{"213df5d04c108c99d3ec9ffe43a53f638f0ede0b"}, sums)
}