test: update git repository unit test

main
sudo pacman -Syu 2021-11-06 14:37:03 +07:00
parent 2580cdd5cd
commit e3487e3c9c
3 changed files with 54 additions and 4 deletions

6
.gitignore vendored
View File

@ -10,7 +10,5 @@
# VSCode
.vscode/
# Node
node_modules/
package.json
package-lock.json
# Go
coverage.out

14
Makefile Normal file
View File

@ -0,0 +1,14 @@
.PHONY: test coverage-cli coverate-html lint
test:
go test -race -coverprofile=coverage.out ./...
coverage-cli: test
go tool cover -func=coverage.out
coverage-html: test
go tool cover -html=coverage.out
lint:
golangci-lint run ./...
semgrep --config auto

View File

@ -0,0 +1,38 @@
package git
import (
"testing"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/storage/memory"
"github.com/stretchr/testify/suite"
)
type RepositorySuite struct {
suite.Suite
r *git.Repository
repo *repo
}
func (s *RepositorySuite) SetupTest() {
var err error
s.r, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
URL: "https://github.com/haunt98/changeloguru",
})
s.NoError(err)
s.repo = &repo{
r: s.r,
}
}
func TestRepositorySuite(t *testing.T) {
suite.Run(t, new(RepositorySuite))
}
func (s *RepositorySuite) TestLogSuccess() {
_, gotErr := s.repo.Log("", "")
s.NoError(gotErr)
}