remove duplicate rows from the summary table (#179)

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman
2020-09-25 10:32:37 -04:00
committed by GitHub
parent 3d91a66536
commit c46d004a3b
2 changed files with 50 additions and 0 deletions
+30
View File
@@ -3,6 +3,7 @@ package table
import (
"bytes"
"flag"
"github.com/go-test/deep"
"testing"
"github.com/anchore/go-testutils"
@@ -64,3 +65,32 @@ func TestTablePresenter(t *testing.T) {
t.Errorf("mismatched output:\n%s", dmp.DiffPrettyText(diffs))
}
}
func TestRemoveDuplicateRows(t *testing.T) {
data := [][]string{
{"1", "2", "3"},
{"a", "b", "c"},
{"1", "2", "3"},
{"a", "b", "c"},
{"1", "2", "3"},
{"4", "5", "6"},
{"1", "2", "1"},
}
expected := [][]string{
{"1", "2", "3"},
{"a", "b", "c"},
{"4", "5", "6"},
{"1", "2", "1"},
}
actual := removeDuplicateRows(data)
if diffs := deep.Equal(expected, actual); len(diffs) > 0 {
t.Errorf("found diffs!")
for _, d := range diffs {
t.Errorf(" diff: %+v", d)
}
}
}