Files
trivy/pkg/dependency/parser/python/pipenv/parse_test.go
Teppei Fukuda c2b46d3c20 refactor: unify Library and Package structs (#6633)
Signed-off-by: knqyf263 <knqyf263@gmail.com>
Co-authored-by: DmitriyLewen <91113035+DmitriyLewen@users.noreply.github.com>
Co-authored-by: DmitriyLewen <dmitriy.lewen@smartforce.io>
2024-05-20 07:15:54 +04:00

49 lines
847 B
Go

package pipenv
import (
"os"
"path"
"sort"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
ftypes "github.com/aquasecurity/trivy/pkg/fanal/types"
)
func TestParse(t *testing.T) {
vectors := []struct {
file string // Test input file
want []ftypes.Package
}{
{
file: "testdata/Pipfile_normal.lock",
want: pipenvNormal,
},
{
file: "testdata/Pipfile_django.lock",
want: pipenvDjango,
},
{
file: "testdata/Pipfile_many.lock",
want: pipenvMany,
},
}
for _, v := range vectors {
t.Run(path.Base(v.file), func(t *testing.T) {
f, err := os.Open(v.file)
require.NoError(t, err)
got, _, err := NewParser().Parse(f)
require.NoError(t, err)
sort.Sort(ftypes.Packages(got))
sort.Sort(ftypes.Packages(v.want))
assert.Equal(t, v.want, got)
})
}
}