feat(go): enrich snapshots with package ownership

This commit is contained in:
Luna 2026-07-22 03:50:55 -07:00
parent 6355fb403d
commit 88d7a6e3b8
No known key found for this signature in database
8 changed files with 149 additions and 54 deletions

View file

@ -0,0 +1,19 @@
// SPDX-License-Identifier: GPL-3.0-or-later
package provenance
import "testing"
func TestParseOwnerMatchesSupportedPackageManagers(t *testing.T) {
cases := []struct{ tool, output, want string }{
{"pacman", "/usr/bin/x is owned by core/example 1.2-1", "core/example 1.2-1"},
{"dpkg", "example: /usr/bin/x", "example"},
{"rpm", "example-1.2-1.x86_64", "example-1.2-1.x86_64"},
{"rpm", "file /tmp/x is not owned by any package", ""},
}
for _, tc := range cases {
if got := parseOwner(tc.tool, tc.output); got != tc.want {
t.Fatalf("%s %q -> %q, want %q", tc.tool, tc.output, got, tc.want)
}
}
}