mirror of
https://github.com/anchore/syft.git
synced 2026-11-02 07:26:34 +01:00
Migrate location-related structs to the file package (#1751)
* migrate location structs to file package Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * replace source.Location refs with file package call Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix linting Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove hardlink test for file based catalogers Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove hardlink test for all-regular-files testing Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * migrate file resolver implementations to separate package Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix linting Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * [wip] migrate resolvers to internal Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * migrate resolvers to syft/internal Signed-off-by: Alex Goodman <alex.goodman@anchore.com> --------- Signed-off-by: Alex Goodman <alex.goodman@anchore.com> Signed-off-by: <>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/anchore/stereoscope/pkg/file"
|
||||
)
|
||||
|
||||
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{
|
||||
LocationData: LocationData{
|
||||
Coordinates: test.coordinates,
|
||||
VirtualPath: test.virtualPath,
|
||||
ref: test.ref,
|
||||
},
|
||||
}
|
||||
assert.Equal(t, l.ID(), test.coordinates.ID())
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user