mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
* add python package relationships Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * nil for empty relationships collections Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * new json schema for optional python requiremenets Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update format snapshots for python packages Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * decompose python parsers more + add tests around plural fields Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update JSON schema with python dep refs Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
package python
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/anchore/syft/syft/file"
|
|
)
|
|
|
|
func Test_parsePyvenvCfgReader(t *testing.T) {
|
|
location := file.NewLocation("/some/bogus/path")
|
|
|
|
tests := []struct {
|
|
name string
|
|
fixture string
|
|
want *virtualEnvInfo
|
|
wantErr require.ErrorAssertionFunc
|
|
}{
|
|
{
|
|
name: "parse basic pyenv file",
|
|
fixture: "test-fixtures/pyenv/good-config",
|
|
want: &virtualEnvInfo{
|
|
Location: location,
|
|
Version: "3.9.5",
|
|
IncludeSystemSitePackages: true,
|
|
},
|
|
},
|
|
{
|
|
name: "trixy config cases",
|
|
fixture: "test-fixtures/pyenv/trixy-config",
|
|
want: &virtualEnvInfo{
|
|
Location: location,
|
|
Version: "3.3.3",
|
|
IncludeSystemSitePackages: true,
|
|
},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if tt.wantErr == nil {
|
|
tt.wantErr = require.NoError
|
|
}
|
|
reader, err := os.Open(tt.fixture)
|
|
require.NoError(t, err)
|
|
|
|
got, err := parsePyvenvCfgReader(file.NewLocationReadCloser(location, reader))
|
|
tt.wantErr(t, err)
|
|
assert.Equal(t, tt.want, got)
|
|
})
|
|
}
|
|
}
|