1
This repository has been archived on 2025-08-19. You can view files and clone it, but cannot push or open issues or pull requests.
Files
go-commitlint/internal/commitlint/commitlint_test.go
Voomra af99bebf91 add: import code
портирован код из старого репозитория https://di9.ru/git/Voomra/Conventional-Commits
2025-07-30 18:44:50 +03:00

36 lines
637 B
Go

package commitlint
import (
"github.com/stretchr/testify/assert"
"os"
"testing"
)
func TestReadCommitMessage(t *testing.T) {
createTmpFile := func() string {
tmpFile, err := os.CreateTemp("", "COMMIT_EDITMSG")
if err != nil {
panic(err)
}
defer func(tmpFile *os.File) {
_ = tmpFile.Close()
}(tmpFile)
_, err = tmpFile.WriteString("Line 1\nLine 2\nLine 3")
if err != nil {
panic(err)
}
return tmpFile.Name()
}
exceptedContent := []string{"Line 1", "Line 2", "Line 3"}
message, err := ReadCommitMessage(createTmpFile())
if err != nil {
panic(err)
}
assert.Equal(t, exceptedContent, message)
}