syft/internal/presenter/packages/table_presenter_test.go
Alex Goodman 706322f826
Add SPDX support (#445)
* add initial spdx support

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* expose FileOwner and use in SPDX presenter

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add initial json support for SPDX

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add remaining package fields

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add spdx license list generation + tests

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* keep fileOwner unexported from pkg

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* restore cli test util

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add external refs to spdx tag-value format

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add golang support to CPE generation

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* use tag-value format as default "spdx" format flavor

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add tests around spdx presenters + refactor presenter tests

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add bouncer exception for spdx tools-golang repo

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* remove spdx model questions

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
2021-06-25 16:30:41 -04:00

50 lines
953 B
Go

package packages
import (
"flag"
"testing"
"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, _, _ := presenterImageInput(t, testImage)
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)
}
}
}