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

Method TestFetchWithPackfileWriter

remote_test.go:378–406  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

376}
377
378func (s *RemoteSuite) TestFetchWithPackfileWriter(c *C) {
379 fs, clean := s.TemporalFilesystem()
380 defer clean()
381
382 fss := filesystem.NewStorage(fs, cache.NewObjectLRUDefault())
383 mock := &mockPackfileWriter{Storer: fss}
384
385 url := s.GetBasicLocalRepositoryURL()
386 r := NewRemote(mock, &config.RemoteConfig{Name: "foo", URLs: []string{url}})
387
388 refspec := config.RefSpec("+refs/heads/*:refs/remotes/origin/*")
389 err := r.Fetch(&FetchOptions{
390 RefSpecs: []config.RefSpec{refspec},
391 })
392
393 c.Assert(err, IsNil)
394
395 var count int
396 iter, err := mock.IterEncodedObjects(plumbing.AnyObject)
397 c.Assert(err, IsNil)
398
399 iter.ForEach(func(plumbing.EncodedObject) error {
400 count++
401 return nil
402 })
403
404 c.Assert(count, Equals, 31)
405 c.Assert(mock.PackfileWriterCalled, Equals, true)
406}
407
408func (s *RemoteSuite) TestFetchNoErrAlreadyUpToDate(c *C) {
409 url := s.GetBasicLocalRepositoryURL()

Callers

nothing calls this directly

Calls 9

FetchMethod · 0.95
NewStorageFunction · 0.92
NewObjectLRUDefaultFunction · 0.92
RefSpecTypeAlias · 0.92
NewRemoteFunction · 0.85
IterEncodedObjectsMethod · 0.65
ForEachMethod · 0.65
TemporalFilesystemMethod · 0.45

Tested by

no test coverage detected