mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-22 07:10:41 -08:00
fix(rpc): add PkgPath field to client / server mode (#1643)
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
|
||||
fos "github.com/aquasecurity/fanal/analyzer/os"
|
||||
ftypes "github.com/aquasecurity/fanal/types"
|
||||
ptypes "github.com/aquasecurity/go-dep-parser/pkg/types"
|
||||
dbTypes "github.com/aquasecurity/trivy-db/pkg/types"
|
||||
"github.com/aquasecurity/trivy-db/pkg/vulnsrc/vulnerability"
|
||||
"github.com/aquasecurity/trivy/pkg/types"
|
||||
@@ -134,68 +133,6 @@ func TestConvertFromRpcPkgs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestConvertFromRpcLibraries(t *testing.T) {
|
||||
type args struct {
|
||||
rpcLibs []*common.Library
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want []ftypes.Package
|
||||
}{
|
||||
{
|
||||
name: "happy path",
|
||||
args: args{
|
||||
rpcLibs: []*common.Library{
|
||||
{Name: "foo", Version: "1.2.3"},
|
||||
{Name: "bar", Version: "4.5.6"},
|
||||
},
|
||||
},
|
||||
want: []ftypes.Package{
|
||||
{Name: "foo", Version: "1.2.3"},
|
||||
{Name: "bar", Version: "4.5.6"},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := ConvertFromRPCLibraries(tt.args.rpcLibs)
|
||||
assert.Equal(t, got, tt.want, tt.name)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestConvertToRpcLibraries(t *testing.T) {
|
||||
type args struct {
|
||||
libs []ptypes.Library
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want []*common.Library
|
||||
}{
|
||||
{
|
||||
name: "happy path",
|
||||
args: args{
|
||||
libs: []ptypes.Library{
|
||||
{Name: "foo", Version: "1.2.3"},
|
||||
{Name: "bar", Version: "4.5.6"},
|
||||
},
|
||||
},
|
||||
want: []*common.Library{
|
||||
{Name: "foo", Version: "1.2.3"},
|
||||
{Name: "bar", Version: "4.5.6"},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := ConvertToRPCLibraries(tt.args.libs)
|
||||
assert.Equal(t, got, tt.want, tt.name)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestConvertToRpcVulns(t *testing.T) {
|
||||
fixedPublishedDate := time.Unix(1257894000, 0)
|
||||
fixedLastModifiedDate := time.Unix(1257894010, 0)
|
||||
|
||||
Reference in New Issue
Block a user