mirror of
https://github.com/anchore/syft.git
synced 2025-11-18 17:03:17 +01:00
* set package ID in catalogers and improve hashing performance Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * update setting ID + tests Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
48 lines
960 B
Go
48 lines
960 B
Go
package source
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/anchore/stereoscope/pkg/file"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestLocation_ID(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
coordinates Coordinates
|
|
virtualPath string
|
|
ref file.Reference
|
|
}{
|
|
{
|
|
name: "coordinates should match location hash",
|
|
coordinates: Coordinates{
|
|
RealPath: "path!",
|
|
FileSystemID: "filesystem!",
|
|
},
|
|
},
|
|
{
|
|
name: "coordinates should match location hash (with extra fields)",
|
|
coordinates: Coordinates{
|
|
RealPath: "path!",
|
|
FileSystemID: "filesystem!",
|
|
},
|
|
virtualPath: "virtualPath!",
|
|
ref: file.Reference{
|
|
RealPath: "other-real-path!",
|
|
},
|
|
},
|
|
}
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
l := Location{
|
|
Coordinates: test.coordinates,
|
|
VirtualPath: test.virtualPath,
|
|
ref: test.ref,
|
|
}
|
|
assert.Equal(t, l.ID(), test.coordinates.ID())
|
|
})
|
|
}
|
|
|
|
}
|