diff --git a/app/ldiff/diff.go b/app/ldiff/diff.go index dd49d980..f0a2f197 100644 --- a/app/ldiff/diff.go +++ b/app/ldiff/diff.go @@ -94,6 +94,8 @@ type Diff interface { Ids() []string // Hash returns hash of all elements in the diff Hash() string + // Len returns count of elements in the diff + Len() int } // Remote interface for using in the Diff @@ -159,6 +161,12 @@ func (d *diff) Ids() (ids []string) { return } +func (d *diff) Len() int { + d.mu.RLock() + defer d.mu.RUnlock() + return d.sl.Len() +} + func (d *diff) Elements() (elements []Element) { d.mu.RLock() defer d.mu.RUnlock() diff --git a/app/ldiff/diff_test.go b/app/ldiff/diff_test.go index 682bf1d5..e15f6b82 100644 --- a/app/ldiff/diff_test.go +++ b/app/ldiff/diff_test.go @@ -179,6 +179,7 @@ func TestDiff_Ids(t *testing.T) { gotIds := d.Ids() sort.Strings(gotIds) assert.Equal(t, ids, gotIds) + assert.Equal(t, len(ids), d.Len()) } func TestDiff_Elements(t *testing.T) {