mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
52 lines
1.0 KiB
Go
52 lines
1.0 KiB
Go
package packages
|
|
|
|
import (
|
|
"flag"
|
|
"testing"
|
|
|
|
"github.com/anchore/syft/internal/formats/common/testutils"
|
|
|
|
"github.com/go-test/deep"
|
|
)
|
|
|
|
var updateTablePresenterGoldenFiles = flag.Bool("update-table", false, "update the *.golden files for table presenters")
|
|
|
|
func TestTablePresenter(t *testing.T) {
|
|
testImage := "image-simple"
|
|
catalog, _, _ := testutils.ImageInput(t, testImage)
|
|
testutils.AssertPresenterAgainstGoldenImageSnapshot(t,
|
|
NewTablePresenter(catalog),
|
|
testImage,
|
|
*updateTablePresenterGoldenFiles,
|
|
)
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|
|
|
|
}
|