Fast implementation of Git in pure Go
at master 30 lines 730 B view raw
1package object_test 2 3import ( 4 "bytes" 5 "testing" 6 7 "codeberg.org/lindenii/furgit/internal/testgit" 8 "codeberg.org/lindenii/furgit/object" 9 "codeberg.org/lindenii/furgit/objectid" 10) 11 12func TestBlobParseFromGit(t *testing.T) { 13 t.Parallel() 14 testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { //nolint:thelper 15 testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 16 body := []byte("hello\nblob\n") 17 blobID := testRepo.HashObject(t, "blob", body) 18 19 rawBody := testRepo.CatFile(t, "blob", blobID) 20 21 blob, err := object.ParseBlob(rawBody) 22 if err != nil { 23 t.Fatalf("ParseBlob: %v", err) 24 } 25 26 if !bytes.Equal(blob.Data, body) { 27 t.Fatalf("blob body mismatch") 28 } 29 }) 30}