add: import code
портирован код из старого репозитория https://di9.ru/git/Voomra/Conventional-Commits
This commit is contained in:
35
internal/commitlint/commitlint_test.go
Normal file
35
internal/commitlint/commitlint_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user