// 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) } } }