blob: 709ccf91133e31566847e8add1c1887540098413 (
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 (
"testing"
"lindenii.org/go/furgit/internal/testgit"
"lindenii.org/go/furgit/object/blob"
objectid "lindenii.org/go/furgit/object/id"
)
func TestBlobSerialize(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")
wantID := testRepo.HashObject(t, "blob", body)
obj := &blob.Blob{Data: body}
rawObj, err := obj.BytesWithHeader()
if err != nil {
t.Fatalf("BytesWithHeader: %v", err)
}
gotID := algo.Sum(rawObj)
if gotID != wantID {
t.Fatalf("object id mismatch: got %s want %s", gotID, wantID)
}
})
}
|