MCPcopy Create free account
hub / github.com/go-git/go-git / TestNewObject

Method TestNewObject

storage/filesystem/dotgit/dotgit_test.go:568–590  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

566}
567
568func (s *SuiteDotGit) TestNewObject(c *C) {
569 fs, clean := s.TemporalFilesystem()
570 defer clean()
571
572 dir := New(fs)
573 w, err := dir.NewObject()
574 c.Assert(err, IsNil)
575
576 err = w.WriteHeader(plumbing.BlobObject, 14)
577 c.Assert(err, IsNil)
578 n, err := w.Write([]byte("this is a test"))
579 c.Assert(err, IsNil)
580 c.Assert(n, Equals, 14)
581
582 c.Assert(w.Hash().String(), Equals, "a8a940627d132695a9769df883f85992f0ff4a43")
583
584 err = w.Close()
585 c.Assert(err, IsNil)
586
587 i, err := fs.Stat("objects/a8/a940627d132695a9769df883f85992f0ff4a43")
588 c.Assert(err, IsNil)
589 c.Assert(i.Size(), Equals, int64(34))
590}
591
592func (s *SuiteDotGit) TestObjects(c *C) {
593 fs := fixtures.ByTag(".git").ByTag("unpacked").One().DotGit()

Callers

nothing calls this directly

Calls 10

TemporalFilesystemMethod · 0.95
NewObjectMethod · 0.80
WriteHeaderMethod · 0.80
StatMethod · 0.80
NewFunction · 0.70
StringMethod · 0.65
HashMethod · 0.65
CloseMethod · 0.65
SizeMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected