blob: 09d5d5d07d8a7cf8dd25dd145429fe3651475df1 (
about) (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
package blob_test
import (
"bytes"
"testing"
"codeberg.org/lindenii/furgit/internal/testgit"
"codeberg.org/lindenii/furgit/object/blob"
objectid "codeberg.org/lindenii/furgit/object/id"
)
func TestBlobParseFromGit(t *testing.T) {
t.Parallel()
testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { //nolint:thelper
testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true})
body := []byte("hello\nblob\n")
blobID := testRepo.HashObject(t, "blob", body)
rawBody := testRepo.CatFile(t, "blob", blobID)
parsed, err := blob.Parse(rawBody)
if err != nil {
t.Fatalf("ParseBlob: %v", err)
}
if !bytes.Equal(parsed.Data, body) {
t.Fatalf("blob body mismatch")
}
})
}
|