github.com/lineaje-labs/syft@v0.98.1-0.20231227153149-9e393f60ff1b/syft/format/table/encoder_test.go (about) 1 package table 2 3 import ( 4 "flag" 5 "testing" 6 7 "github.com/go-test/deep" 8 9 "github.com/lineaje-labs/syft/syft/format/internal/testutil" 10 ) 11 12 var updateSnapshot = flag.Bool("update-table", false, "update the *.golden files for table format") 13 14 func TestTableEncoder(t *testing.T) { 15 testutil.AssertEncoderAgainstGoldenSnapshot(t, 16 testutil.EncoderSnapshotTestConfig{ 17 Subject: testutil.DirectoryInput(t, t.TempDir()), 18 Format: NewFormatEncoder(), 19 UpdateSnapshot: *updateSnapshot, 20 PersistRedactionsInSnapshot: true, 21 IsJSON: false, 22 }, 23 ) 24 } 25 26 func TestRemoveDuplicateRows(t *testing.T) { 27 data := [][]string{ 28 {"1", "2", "3"}, 29 {"a", "b", "c"}, 30 {"1", "2", "3"}, 31 {"a", "b", "c"}, 32 {"1", "2", "3"}, 33 {"4", "5", "6"}, 34 {"1", "2", "1"}, 35 } 36 37 expected := [][]string{ 38 {"1", "2", "3"}, 39 {"a", "b", "c"}, 40 {"4", "5", "6"}, 41 {"1", "2", "1"}, 42 } 43 44 actual := removeDuplicateRows(data) 45 46 if diffs := deep.Equal(expected, actual); len(diffs) > 0 { 47 t.Errorf("found diffs!") 48 for _, d := range diffs { 49 t.Errorf(" diff: %+v", d) 50 } 51 } 52 53 }