1
0
Fork 0
mirror of https://github.com/Luzifer/ansible-role-version.git synced 2024-12-24 11:31:21 +00:00
ansible-role-version/vendor/gopkg.in/src-d/go-git.v4/plumbing/object_test.go

47 lines
1.3 KiB
Go
Raw Normal View History

package plumbing
import . "gopkg.in/check.v1"
type ObjectSuite struct{}
var _ = Suite(&ObjectSuite{})
func (s *ObjectSuite) TestObjectTypeString(c *C) {
c.Assert(CommitObject.String(), Equals, "commit")
c.Assert(TreeObject.String(), Equals, "tree")
c.Assert(BlobObject.String(), Equals, "blob")
c.Assert(TagObject.String(), Equals, "tag")
c.Assert(REFDeltaObject.String(), Equals, "ref-delta")
c.Assert(OFSDeltaObject.String(), Equals, "ofs-delta")
c.Assert(AnyObject.String(), Equals, "any")
c.Assert(ObjectType(42).String(), Equals, "unknown")
}
func (s *ObjectSuite) TestObjectTypeBytes(c *C) {
c.Assert(CommitObject.Bytes(), DeepEquals, []byte("commit"))
}
func (s *ObjectSuite) TestObjectTypeValid(c *C) {
c.Assert(CommitObject.Valid(), Equals, true)
c.Assert(ObjectType(42).Valid(), Equals, false)
}
func (s *ObjectSuite) TestParseObjectType(c *C) {
for s, e := range map[string]ObjectType{
"commit": CommitObject,
"tree": TreeObject,
"blob": BlobObject,
"tag": TagObject,
"ref-delta": REFDeltaObject,
"ofs-delta": OFSDeltaObject,
} {
t, err := ParseObjectType(s)
c.Assert(err, IsNil)
c.Assert(e, Equals, t)
}
t, err := ParseObjectType("foo")
c.Assert(err, Equals, ErrInvalidType)
c.Assert(t, Equals, InvalidObject)
}