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

Method TestCreateBranchUnmarshal

repository_test.go:549–590  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

547}
548
549func (s *RepositorySuite) TestCreateBranchUnmarshal(c *C) {
550 r, _ := Init(memory.NewStorage(), nil)
551
552 expected := []byte(`[core]
553 bare = true
554[remote "foo"]
555 url = http://foo/foo.git
556 fetch = +refs/heads/*:refs/remotes/foo/*
557[branch "foo"]
558 remote = origin
559 merge = refs/heads/foo
560[branch "master"]
561 remote = origin
562 merge = refs/heads/master
563`)
564
565 _, err := r.CreateRemote(&config.RemoteConfig{
566 Name: "foo",
567 URLs: []string{"http://foo/foo.git"},
568 })
569 c.Assert(err, IsNil)
570 testBranch1 := &config.Branch{
571 Name: "master",
572 Remote: "origin",
573 Merge: "refs/heads/master",
574 }
575 testBranch2 := &config.Branch{
576 Name: "foo",
577 Remote: "origin",
578 Merge: "refs/heads/foo",
579 }
580 err = r.CreateBranch(testBranch1)
581 c.Assert(err, IsNil)
582 err = r.CreateBranch(testBranch2)
583 c.Assert(err, IsNil)
584
585 cfg, err := r.Config()
586 c.Assert(err, IsNil)
587 marshaled, err := cfg.Marshal()
588 c.Assert(err, IsNil)
589 c.Assert(string(expected), Equals, string(marshaled))
590}
591
592func (s *RepositorySuite) TestBranchInvalid(c *C) {
593 r, _ := Init(memory.NewStorage(), nil)

Callers

nothing calls this directly

Calls 6

NewStorageFunction · 0.92
InitFunction · 0.85
CreateRemoteMethod · 0.80
CreateBranchMethod · 0.80
ConfigMethod · 0.65
MarshalMethod · 0.45

Tested by

no test coverage detected