MCPcopy
hub / github.com/go-git/go-git / TestNewObject

Method TestNewObject

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

Source from the content-addressed store, hash-verified

594}
595
596func (s *SuiteDotGit) TestNewObject(c *C) {
597 fs := s.TemporalFilesystem(c)
598
599 dir := New(fs)
600 w, err := dir.NewObject()
601 c.Assert(err, IsNil)
602
603 err = w.WriteHeader(plumbing.BlobObject, 14)
604 c.Assert(err, IsNil)
605 n, err := w.Write([]byte("this is a test"))
606 c.Assert(err, IsNil)
607 c.Assert(n, Equals, 14)
608
609 c.Assert(w.Hash().String(), Equals, "a8a940627d132695a9769df883f85992f0ff4a43")
610
611 err = w.Close()
612 c.Assert(err, IsNil)
613
614 i, err := fs.Stat("objects/a8/a940627d132695a9769df883f85992f0ff4a43")
615 c.Assert(err, IsNil)
616 c.Assert(i.Size(), Equals, int64(34))
617}
618
619func (s *SuiteDotGit) TestObjects(c *C) {
620 fs := fixtures.ByTag(".git").ByTag("unpacked").One().DotGit()

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected