This commit is contained in:
2024-07-16 14:52:35 +02:00
parent 75c0089807
commit 71aa592fb1
2 changed files with 43 additions and 5 deletions

View File

@@ -1,6 +1,10 @@
package common
import (
"os"
"os/exec"
"path"
"strings"
"testing"
)
@@ -64,7 +68,7 @@ func TestGitMsgParsing(t *testing.T) {
}
gitHdr, err := parseGitMsg(data)
if err.Error() != "Invalid character during object hash parse" {
if err.Error() != "Invalid character during object hash parse 'r' at 4" {
t.Error(err)
}
@@ -220,10 +224,33 @@ Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>` + "\x00"
})
}
/*func TestCommitTreeParsingOfHead(t *testing.T) {
t.Run("reads HEAD and parses the tree", func (t *testing.T) {
func TestCommitTreeParsingOfHead(t *testing.T) {
gitDir := t.TempDir()
testDir, _ := os.Getwd()
var commitId string
cmd := exec.Command("/usr/bin/bash", path.Join(testDir, "tsetup.sh"))
cmd.Dir = gitDir
cmd.Stdout = writeFunc(func(data []byte) (int, error) {
commitId = commitId + strings.TrimSpace(string(data))
return len(data), nil
})
if err := cmd.Run(); err != nil {
t.Fatal(err.Error())
}
}
*/
t.Run("reads HEAD and parses the tree", func(t *testing.T) {
const nodejs21 = "c678c57007d496a98bec668ae38f2c26a695f94af78012f15d044ccf066ccb41"
h := RequestHandler{
GitPath: gitDir,
Logger: CreateTestLogger(t),
}
id, ok := h.GitSubmoduleCommitId("", "nodejs21", commitId)
if !ok {
t.Error("failed parse")
}
if id != nodejs21 {
t.Errorf("hash doesn't match: %s vs. expected %s", id, nodejs21)
}
})
}