1
0
Fork 0
mirror of https://github.com/Luzifer/ansible-role-version.git synced 2024-12-23 19:11:20 +00:00
ansible-role-version/vendor/gopkg.in/src-d/go-git.v4/plumbing/object_test.go
Knut Ahlers 209b813c5b
Update dependencies
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2018-03-19 18:16:10 +01:00

46 lines
1.3 KiB
Go

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)
}