dnfjson: remove single Depsolve function and command

Remove the single Depsolve function from the dnfjson package and the
depsolve command from the dnf-json tool.  The new ChainDepsolve
functions and chain-depsolve command can handle single depsolves in the
same way so there's no need to keep (and have to maintain) two versions
of very similar code.

The ChainDepsolve function (in Go) and chain-depsolve command (in
Python) have been renamed to plain Depsolve and depsolve respectively,
since they are now general purpose depsolve functions.
This commit is contained in:
Achilleas Koutsou 2022-05-04 13:01:32 +02:00 committed by Tom Gundersen
parent d09176893b
commit 61d7c465af
11 changed files with 35 additions and 149 deletions

View file

@ -19,29 +19,10 @@ func TestDepsolver(t *testing.T) {
solver := NewSolver("platform:el9", "9", "x86_64", tmpdir)
solver.SetDNFJSONPath("../../dnf-json")
pkgset := rpmmd.PackageSet{Include: []string{"kernel", "vim-minimal", "tmux", "zsh"}} // everything you'll ever need
deps, err := solver.Depsolve(pkgset, []rpmmd.RepoConfig{s.RepoConfig})
if err != nil {
t.Fatal(err)
}
exp := expectedResult(s.Server.URL)
assert.Equal(deps, exp)
}
func TestChainDepsolver(t *testing.T) {
s := rpmrepo.NewTestServer()
defer s.Close()
assert := assert.New(t)
tmpdir := t.TempDir()
solver := NewSolver("platform:el9", "9", "x86_64", tmpdir)
solver.SetDNFJSONPath("../../dnf-json")
{ // single depsolve, but using chain function, should behave the same way as plain Depsolve
{ // single depsolve
pkgsets := []rpmmd.PackageSet{{Include: []string{"kernel", "vim-minimal", "tmux", "zsh"}}} // everything you'll ever need
deps, err := solver.ChainDepsolve(pkgsets, []rpmmd.RepoConfig{s.RepoConfig}, nil)
deps, err := solver.Depsolve(pkgsets, []rpmmd.RepoConfig{s.RepoConfig}, nil)
if err != nil {
t.Fatal(err)
}
@ -54,7 +35,7 @@ func TestChainDepsolver(t *testing.T) {
{Include: []string{"kernel"}},
{Include: []string{"vim-minimal", "tmux", "zsh"}},
}
deps, err := solver.ChainDepsolve(pkgsets, []rpmmd.RepoConfig{s.RepoConfig}, nil)
deps, err := solver.Depsolve(pkgsets, []rpmmd.RepoConfig{s.RepoConfig}, nil)
if err != nil {
t.Fatal(err)
}
@ -67,7 +48,7 @@ func TestChainDepsolver(t *testing.T) {
{Include: []string{"kernel"}},
{Include: []string{"vim-minimal", "tmux", "zsh"}},
}
deps, err := solver.ChainDepsolve(pkgsets, []rpmmd.RepoConfig{s.RepoConfig}, [][]rpmmd.RepoConfig{nil, {s.RepoConfig}})
deps, err := solver.Depsolve(pkgsets, []rpmmd.RepoConfig{s.RepoConfig}, [][]rpmmd.RepoConfig{nil, {s.RepoConfig}})
if err != nil {
t.Fatal(err)
}
@ -76,7 +57,7 @@ func TestChainDepsolver(t *testing.T) {
}
}
func TestMakeChainDepsolveRequest(t *testing.T) {
func TestMakeDepsolveRequest(t *testing.T) {
tests := []struct {
packageSets []rpmmd.PackageSet
repos []rpmmd.RepoConfig
@ -464,7 +445,7 @@ func TestMakeChainDepsolveRequest(t *testing.T) {
solver := NewSolver("", "", "", "")
for idx, tt := range tests {
t.Run(fmt.Sprintf("%d", idx), func(t *testing.T) {
req, err := solver.makeChainDepsolveRequest(tt.packageSets, tt.repos, tt.packageSetsRepos)
req, err := solver.makeDepsolveRequest(tt.packageSets, tt.repos, tt.packageSetsRepos)
if tt.err {
assert.NotNilf(t, err, "expected an error, but got 'nil' instead")
assert.Nilf(t, req, "got non-nill request, but expected an error")