aboutsummaryrefslogtreecommitdiff
path: root/object/blob_parse_test.go
blob: ea0a279ee3191eb1dd39beadb4132c7cfb041824 (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
package object_test

import (
	"bytes"
	"testing"

	"codeberg.org/lindenii/furgit/internal/testgit"
	"codeberg.org/lindenii/furgit/object"
	"codeberg.org/lindenii/furgit/objectid"
)

func TestBlobParseFromGit(t *testing.T) {
	testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {
		testRepo := testgit.NewBareRepo(t, algo)
		body := []byte("hello\nblob\n")
		blobID := testRepo.HashObject(t, "blob", body)

		rawBody := testRepo.CatFile(t, "blob", blobID)
		blob, err := object.ParseBlob(rawBody)
		if err != nil {
			t.Fatalf("ParseBlob: %v", err)
		}
		if !bytes.Equal(blob.Data, body) {
			t.Fatalf("blob body mismatch")
		}
	})
}