Add utils for Archlinux

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>
This commit is contained in:
Nicolas Lamirault 2016-01-05 13:31:17 +01:00
parent c7fe1f5726
commit 58cdb88537
2 changed files with 7 additions and 3 deletions

View File

@ -15,7 +15,6 @@
package packages package packages
import ( import (
"os/exec"
"testing" "testing"
"github.com/coreos/clair/database" "github.com/coreos/clair/database"
@ -43,8 +42,7 @@ var rpmPackagesTests = []packagesTest{
} }
func TestRpmPackagesDetector(t *testing.T) { func TestRpmPackagesDetector(t *testing.T) {
_, err := exec.LookPath("rpm") if checkPackageManager("rpm") != nil {
if err != nil {
log.Warningf("could not find rpm executable. skipping") log.Warningf("could not find rpm executable. skipping")
return return
} }

View File

@ -16,6 +16,7 @@ package packages
import ( import (
"io/ioutil" "io/ioutil"
"os/exec"
"path" "path"
"runtime" "runtime"
"testing" "testing"
@ -36,6 +37,11 @@ func loadFileForTest(name string) []byte {
return d return d
} }
func checkPackageManager(name string) error {
_, err := exec.LookPath(name)
return err
}
func testPackagesDetector(t *testing.T, detector detectors.PackagesDetector, tests []packagesTest) { func testPackagesDetector(t *testing.T, detector detectors.PackagesDetector, tests []packagesTest) {
for _, test := range tests { for _, test := range tests {
packages, err := detector.Detect(test.data) packages, err := detector.Detect(test.data)