diff --git a/.gitignore b/.gitignore index f3cb1a5..09e1669 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,5 @@ # VSCode .vscode/ -# Node -node_modules/ -package.json -package-lock.json +# Go +coverage.out diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3785377 --- /dev/null +++ b/Makefile @@ -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 diff --git a/internal/git/repository_test.go b/internal/git/repository_test.go new file mode 100644 index 0000000..baaf0db --- /dev/null +++ b/internal/git/repository_test.go @@ -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) +}