chore: update ffmpeg tests (#4249)

Signed-off-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
Keith Zantow 2025-10-01 09:11:36 -04:00 committed by GitHub
parent 605a275dd3
commit 9217f2099f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 5 deletions

View File

@ -1399,7 +1399,7 @@ func Test_Cataloger_PositiveCases(t *testing.T) {
Version: "5.1.4",
Type: "binary",
PURL: "pkg:generic/ffmpeg@5.1.4",
Locations: locations("libavcodec"),
Locations: locations("libavcodec-9aae324f.so.59.37.100"),
Metadata: metadata("ffmpeg-library"),
},
},

View File

@ -838,7 +838,4 @@ from-images:
platform: linux/amd64
paths:
- /usr/local/lib/python3.11/site-packages/opencv_contrib_python.libs/libavcodec-9aae324f.so.59.37.100
- /usr/local/lib/python3.11/site-packages/opencv_contrib_python.libs/libavformat-3ff1be5b.so.59.27.100
- /usr/local/lib/python3.11/site-packages/opencv_contrib_python.libs/libavutil-a0a0531e.so.57.28.100
- /usr/local/lib/python3.11/site-packages/opencv_contrib_python.libs/libswresample-2ec4394e.so.4.7.100

View File

@ -2,11 +2,15 @@ package internal
import (
"fmt"
"iter"
"os"
"path/filepath"
"slices"
"sort"
"strings"
"golang.org/x/exp/maps"
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config"
)
@ -195,3 +199,17 @@ func (e Entries) BinaryFromImageHasSnippet(cfg config.BinaryFromImage) bool {
}
return true
}
func (e Entries) Sorted() iter.Seq2[LogicalEntryKey, EntryInfo] {
keys := maps.Keys(e)
slices.SortFunc(keys, func(a, b LogicalEntryKey) int {
return strings.Compare(a.Path(), b.Path())
})
return func(yield func(LogicalEntryKey, EntryInfo) bool) {
for _, k := range keys {
if !yield(k, e[k]) {
return
}
}
}
}

View File

@ -42,7 +42,7 @@ func SnippetOrBinary(t *testing.T, path string, requireBinary bool) string {
require.NoError(t, err)
var fixturePath string
for k, v := range entries {
for k, v := range entries.Sorted() {
if filepath.Dir(k.Path()) == path {
// prefer the snippet over the binary
if !requireBinary {