test: update git repository unit test
parent
2580cdd5cd
commit
e3487e3c9c
|
@ -10,7 +10,5 @@
|
|||
# VSCode
|
||||
.vscode/
|
||||
|
||||
# Node
|
||||
node_modules/
|
||||
package.json
|
||||
package-lock.json
|
||||
# Go
|
||||
coverage.out
|
||||
|
|
|
@ -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
|
|
@ -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)
|
||||
}
|
Loading…
Reference in New Issue