From 187c74523c5a0565c2d02a1691233790d773aa4e Mon Sep 17 00:00:00 2001 From: Weston Steimel Date: Fri, 24 Feb 2023 21:11:24 +0000 Subject: [PATCH] tests for vendor from url logic Signed-off-by: Weston Steimel --- .../common/cpe/vendors_from_url_test.go | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 syft/pkg/cataloger/common/cpe/vendors_from_url_test.go diff --git a/syft/pkg/cataloger/common/cpe/vendors_from_url_test.go b/syft/pkg/cataloger/common/cpe/vendors_from_url_test.go new file mode 100644 index 000000000000..75dac3ba94f7 --- /dev/null +++ b/syft/pkg/cataloger/common/cpe/vendors_from_url_test.go @@ -0,0 +1,36 @@ +package cpe + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_candidateVendorsFromURL(t *testing.T) { + tests := []struct { + name string + url string + expected []string + }{ + { + name: "empty", + url: "", + expected: []string{}, + }, + { + name: "no known vendors", + url: "https://something-unknown.com/126374623876/12345", + expected: []string{}, + }, + { + name: "gnu vendor from url", + url: "https://www.gnu.org/software/make", + expected: []string{"gnu"}, + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + assert.ElementsMatch(t, test.expected, candidateVendorsFromURL(test.url).uniqueValues(), "different vendors") + }) + } +}