mirror of
https://github.com/anchore/syft.git
synced 2026-11-02 15:36:41 +01:00
* add nix DB cataloger Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add derivation path to nix store pkg metadata Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * go mod tidy Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * allow for derivation path to be optional Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * repin build image and disable syscall filtering Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * bump storage capacity Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * track nix derivation details on packages Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * image fixture should have derivation examples Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * address comments Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
60 lines
1.3 KiB
Go
60 lines
1.3 KiB
Go
package nix
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func Test_packageURL(t *testing.T) {
|
|
|
|
tests := []struct {
|
|
name string
|
|
storePath nixStorePath
|
|
drvPath string
|
|
want string
|
|
}{
|
|
{
|
|
name: "name + version",
|
|
storePath: nixStorePath{
|
|
Name: "glibc",
|
|
Version: "2.34",
|
|
},
|
|
want: "pkg:nix/glibc@2.34",
|
|
},
|
|
{
|
|
name: "hash qualifier",
|
|
storePath: nixStorePath{
|
|
Name: "glibc",
|
|
Version: "2.34",
|
|
OutputHash: "h0cnbmfcn93xm5dg2x27ixhag1cwndga",
|
|
},
|
|
want: "pkg:nix/glibc@2.34?outputhash=h0cnbmfcn93xm5dg2x27ixhag1cwndga",
|
|
},
|
|
{
|
|
name: "output qualifier",
|
|
storePath: nixStorePath{
|
|
Name: "glibc",
|
|
Version: "2.34",
|
|
OutputHash: "h0cnbmfcn93xm5dg2x27ixhag1cwndga",
|
|
Output: "bin",
|
|
},
|
|
want: "pkg:nix/glibc@2.34?output=bin&outputhash=h0cnbmfcn93xm5dg2x27ixhag1cwndga",
|
|
},
|
|
{
|
|
name: "derivation qualifier",
|
|
storePath: nixStorePath{
|
|
Name: "glibc",
|
|
Version: "2.34",
|
|
},
|
|
drvPath: "/nix/store/h0cnbmfcn93xm5dg2x27ixhag1cwndga-glibc-2.34.drv",
|
|
want: "pkg:nix/glibc@2.34?drvpath=h0cnbmfcn93xm5dg2x27ixhag1cwndga-glibc-2.34.drv",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
assert.Equal(t, tt.want, packageURL(tt.storePath, tt.drvPath))
|
|
})
|
|
}
|
|
}
|