feat(go): enrich snapshots with package ownership
This commit is contained in:
parent
6355fb403d
commit
88d7a6e3b8
8 changed files with 149 additions and 54 deletions
19
go-agent/internal/provenance/provenance_test.go
Normal file
19
go-agent/internal/provenance/provenance_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue