99 "testing"
1010
1111 "github.com/stretchr/testify/assert"
12+ "github.com/stretchr/testify/require"
1213)
1314
1415func TestTreeEntry (t * testing.T ) {
@@ -31,6 +32,39 @@ func TestTreeEntry(t *testing.T) {
3132 assert .Equal (t , "go.mod" , e .Name ())
3233}
3334
35+ func TestTreeEntry_Size (t * testing.T ) {
36+ ctx := context .Background ()
37+ tree , err := testrepo .LsTree (ctx , "0eedd79eba4394bbef888c804e899731644367fe" )
38+ require .NoError (t , err )
39+
40+ es , err := tree .Entries (ctx )
41+ require .NoError (t , err )
42+
43+ t .Run ("blob" , func (t * testing.T ) {
44+ var entry * TreeEntry
45+ for _ , e := range es {
46+ if e .Name () == "README.txt" {
47+ entry = e
48+ break
49+ }
50+ }
51+ require .NotNil (t , entry , "entry README.txt not found" )
52+ assert .Equal (t , int64 (795 ), entry .Size (ctx ))
53+ })
54+
55+ t .Run ("tree returns zero" , func (t * testing.T ) {
56+ var entry * TreeEntry
57+ for _ , e := range es {
58+ if e .IsTree () {
59+ entry = e
60+ break
61+ }
62+ }
63+ require .NotNil (t , entry , "tree entry not found" )
64+ assert .Equal (t , int64 (0 ), entry .Size (ctx ))
65+ })
66+ }
67+
3468func TestEntries_Sort (t * testing.T ) {
3569 ctx := context .Background ()
3670 tree , err := testrepo .LsTree (ctx , "0eedd79eba4394bbef888c804e899731644367fe" )
0 commit comments