This commit is contained in:
2024-07-29 15:28:03 +02:00
parent 65d821d388
commit 249fbab882
4 changed files with 178 additions and 37 deletions

View File

@@ -88,7 +88,7 @@ func TestGitMsgParsing(t *testing.T) {
func TestGitCommitParsing(t *testing.T) {
t.Run("parse valid commit message", func(t *testing.T) {
const commitData = "f40888ea4515fe2e8eea617a16f5f50a45f652d894de3ad181d58de3aafb8f99 commit 254\000" +
const commitData = "f40888ea4515fe2e8eea617a16f5f50a45f652d894de3ad181d58de3aafb8f99 commit 253\000" +
`tree e20033df9f18780756ba4a96dbc7eb1a626253961039cb674156f266ba7a4e53
parent 429cc2fe02170ca5668f0461928c7e7430c7a17cd64ac298286d7162572a7703
author Adam Majer <amajer@suse.com> 1720709149 +0200
@@ -115,7 +115,7 @@ committer Adam Majer <amajer@suse.com> 1720709149 +0200
})
t.Run("parse multiline headers", func(t *testing.T) {
const commitData = "cae5831ab48470ff060a5aaa12eb6e5a7acaf91e commit 1492\x00" +
const commitData = "cae5831ab48470ff060a5aaa12eb6e5a7acaf91e commit 1491\x00" +
`tree 1f9c8fe8099615d6d3921528402ac53f09213b02
parent e08a654fae0ecc91678819e0b62a2e014bad3339
author Yagiz Nizipli <yagiz@nizipli.com> 1720967314 -0400
@@ -253,4 +253,22 @@ func TestCommitTreeParsingOfHead(t *testing.T) {
t.Errorf("hash doesn't match: %s vs. expected %s", id, nodejs21)
}
})
t.Run("reads README.md", func (t *testing.T) {
h := RequestHandler{
GitPath: gitDir,
Logger: CreateTestLogger(t),
}
data := h.GitCatFile("", commitId, "README.md")
if h.HasError() {
t.Errorf("failed parse: %v", h.Error)
}
if string(data) != "foo\n" || len(data) != 4 {
t.Errorf("Wrong data of len: %d", len(data))
}
})
t.Run("try to parse unknown item", func(t *testing.T) {
})
}