rpmmd: require the path to dnf-json to be passed in

RPMMD had hardcoded path to dnf-json helper. This required all executables
using RPMMD to be run in the directory where dnf-json was located. This commit
makes RPMMD take the path to dnf-json as an argument. This allows its
consumers to specify whichever path they want.

Not a functional change
This commit is contained in:
Ondřej Budai 2020-05-19 08:58:15 +02:00 committed by Tom Gundersen
parent 5b2c06b3da
commit b93df4b524
5 changed files with 20 additions and 14 deletions

View file

@ -34,7 +34,8 @@ func TestFetchChecksum(t *testing.T) {
BaseURL: fmt.Sprintf("file://%s", dir),
IgnoreSSL: true,
}
rpmMetadata := rpmmd.NewRPMMD(path.Join(dir, "rpmmd"))
rpmMetadata := rpmmd.NewRPMMD(path.Join(dir, "rpmmd"), "./dnf-json")
_, c, err := rpmMetadata.FetchMetadata([]rpmmd.RepoConfig{repoCfg}, "platform:f31", "x86_64")
assert.Nilf(t, err, "Failed to fetch checksum: %v", err)
assert.NotEqual(t, "", c["repo"], "The checksum is empty")
@ -58,7 +59,8 @@ func TestCrossArchDepsolve(t *testing.T) {
dir, err := ioutil.TempDir("/tmp", "rpmmd-test-")
require.Nilf(t, err, "Failed to create tmp dir for depsolve test: %v", err)
defer os.RemoveAll(dir)
rpm := rpmmd.NewRPMMD(dir)
rpm := rpmmd.NewRPMMD(dir, "./dnf-json")
repos, err := rpmmd.LoadRepositories([]string{repoDir}, distroStruct.Name())
require.NoErrorf(t, err, "Failed to LoadRepositories %v", distroStruct.Name())