Skip to content

Commit 9bbaa1a

Browse files
authored
Fix commit_file_stats function (#926)
Fix commit_file_stats function
2 parents d2120e7 + 78947e2 commit 9bbaa1a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

internal/function/commit_file_stats.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (f *CommitFileStats) WithChildren(children ...sql.Expression) (sql.Expressi
6666
to = children[1]
6767
}
6868

69-
return &CommitStats{repo, from, to}, nil
69+
return &CommitFileStats{repo, from, to}, nil
7070
}
7171

7272
// Children implements the Expression interface.

internal/function/commit_file_stats_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package function
22

33
import (
44
"context"
5+
6+
"reflect"
57
"testing"
68

79
"github.com/src-d/gitbase"
@@ -80,3 +82,17 @@ func TestCommitFileStats(t *testing.T) {
8082
})
8183
}
8284
}
85+
86+
func TestWithChildren(t *testing.T) {
87+
repo := expression.NewGetField(0, sql.Text, "repository_id", false)
88+
from := expression.NewGetField(2, sql.Text, "commit_hash", false)
89+
90+
cfs, err := NewCommitFileStats(repo, from)
91+
require.NoError(t, err)
92+
93+
newCfs, err := cfs.WithChildren(repo, from)
94+
95+
require.NoError(t, err)
96+
require.EqualValues(t, cfs.Children(), newCfs.Children())
97+
require.Equal(t, reflect.TypeOf(cfs), reflect.TypeOf(newCfs))
98+
}

0 commit comments

Comments
 (0)