mirror of
https://github.com/anchore/syft.git
synced 2025-11-20 18:03:16 +01:00
chore: update packageurl-go dependency to use latest commits chore: go mod tidy unit: update + -> %2B --------- Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package python
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/anchore/syft/syft/pkg"
|
|
)
|
|
|
|
func Test_packageURL(t *testing.T) {
|
|
tests := []struct {
|
|
testName string
|
|
name string
|
|
version string
|
|
metadata *pkg.PythonPackage
|
|
want string
|
|
}{
|
|
{
|
|
testName: "without metadata",
|
|
name: "name",
|
|
version: "v0.1.0",
|
|
want: "pkg:pypi/name@v0.1.0",
|
|
},
|
|
{
|
|
testName: "with vcs info",
|
|
name: "name",
|
|
version: "v0.1.0",
|
|
metadata: &pkg.PythonPackage{
|
|
Name: "bogus", // note: ignored
|
|
Version: "v0.2.0", // note: ignored
|
|
DirectURLOrigin: &pkg.PythonDirectURLOriginInfo{
|
|
VCS: "git",
|
|
URL: "https://github.com/test/test.git",
|
|
CommitID: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
|
},
|
|
},
|
|
want: "pkg:pypi/name@v0.1.0?vcs_url=git%2Bhttps://github.com/test/test.git%40aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.testName, func(t *testing.T) {
|
|
assert.Equal(t, tt.want, packageURL(tt.name, tt.version, tt.metadata))
|
|
})
|
|
}
|
|
}
|