aboutsummaryrefslogblamecommitdiffstats
path: root/plumbing/format/index/index_test.go
blob: cad5f9c194bbb55c4128394fb32868aef8cfd66b (plain) (tree)
1
2
3
4
5
6
7
8
9







                                           
                                  









                                                
                          
                                               
 
















                                                
package index

import (
	. "gopkg.in/check.v1"
)

func (s *IndexSuite) TestIndexEntry(c *C) {
	idx := &Index{
		Entries: []*Entry{
			{Name: "foo", Size: 42},
			{Name: "bar", Size: 82},
		},
	}

	e, err := idx.Entry("foo")
	c.Assert(err, IsNil)
	c.Assert(e.Name, Equals, "foo")

	e, err = idx.Entry("missing")
	c.Assert(e, IsNil)
	c.Assert(err, Equals, ErrEntryNotFound)
}

func (s *IndexSuite) TestIndexRemove(c *C) {
	idx := &Index{
		Entries: []*Entry{
			{Name: "foo", Size: 42},
			{Name: "bar", Size: 82},
		},
	}

	e, err := idx.Remove("foo")
	c.Assert(err, IsNil)
	c.Assert(e.Name, Equals, "foo")

	e, err = idx.Remove("foo")
	c.Assert(e, IsNil)
	c.Assert(err, Equals, ErrEntryNotFound)
}