aboutsummaryrefslogblamecommitdiffstats
path: root/options_test.go
blob: b9e909683acc7a1bb0e236e62abeaa97d7cf4ab3 (plain) (tree)
1
2
3
4
5



                             
                                                     





























                                                               
package git

import (
	. "gopkg.in/check.v1"
	"github.com/go-git/go-git/v5/plumbing/object"
)

type OptionsSuite struct {
	BaseSuite
}

var _ = Suite(&OptionsSuite{})

func (s *OptionsSuite) TestCommitOptionsParentsFromHEAD(c *C) {
	o := CommitOptions{Author: &object.Signature{}}
	err := o.Validate(s.Repository)
	c.Assert(err, IsNil)
	c.Assert(o.Parents, HasLen, 1)
}

func (s *OptionsSuite) TestCommitOptionsMissingAuthor(c *C) {
	o := CommitOptions{}
	err := o.Validate(s.Repository)
	c.Assert(err, Equals, ErrMissingAuthor)
}

func (s *OptionsSuite) TestCommitOptionsCommitter(c *C) {
	sig := &object.Signature{}

	o := CommitOptions{Author: sig}
	err := o.Validate(s.Repository)
	c.Assert(err, IsNil)

	c.Assert(o.Committer, Equals, o.Author)
}