Commit graph

2 commits

Author SHA1 Message Date
Achilleas Koutsou
d0da8fd122 dnfjson: add package tests
The rpmrepo mock contains code to be used for testing depsolving.  It
creates a file server that serves the metadata in test/data/testrepo and
can be used as a repository for depsolve tests.

The dnfjson tests perform a single depsolve with an expected response.
The chain depsolve tests perform multiple depsolves that should produce
the same expected response:
- Single transaction using the ChainDepsove() function
- Two transactions for the same packages split in two with no extra
  repositories
- Two transactions for the same packages split in two with the main
  repository redefined

dnfjsontest: squash
2022-06-01 11:36:52 +01:00
Achilleas Koutsou
4b289ce861 New package: dnfjson
This package is meant to serve as the interface between osbuild-composer
and the (new, upcoming) dnf-json.  It defines structures and functions
for calling the dnf-json commands ("depsolve" and "dump").  The package
uses the rpmmd types to interface with osbuild-composer and converts
them to the necessary representations (for dnf-json) internally.  New
types aren't made public unless necessary.

A lot of the functions and types are copied or adapted from the rpmmd
package and those will eventually be removed.  The rpmmd package will
remain to manage RPM package representations and conversion functions.

The FetchMetadata() function sorts the packages it will return, as does
the original implementation in rpmmd, but now the sort key is the NVR.
This is to make package order stable when multiple packages have the
same name (multiple version of the same package).  This way, the
'builds' arrays of the resulting package infos will also have a stable
order.

The request and result structures differ from the current implementation
of dnf-json.  The change is meant to simplify handling multiple
depsolves with the same dnf.Base object and the new dnf-json tool will
be made to handle this request structure.

The dnf-json command is configurable and supports command line arguments
if necessary.

Signed-off-by: Achilleas Koutsou <achilleas@koutsou.net>
2022-06-01 11:36:52 +01:00