dnf-json-tests: use subtests in TestCrossArchDepsolve
For one, this allows us to use `require` instead of `assert` and
`continue`, which was awkward to read. That works because it's ok to
fail a subtest: the remaining subtests are executed after it.
Also, this shows which test was executed, making debugging easier:
=== RUN TestCrossArchDepsolve
=== RUN TestCrossArchDepsolve/fedora-30
=== RUN TestCrossArchDepsolve/fedora-30/x86_64
=== RUN TestCrossArchDepsolve/fedora-30/x86_64/ami
...
You can now also run those sub tests in isolation:
osbuild-dnf-json-tests -test.run TestCrossArchDepsolve/fedora-30/x86_64/ami
Lastly, it enables running those tests in parallel (not part of this
patch) by calling `t.Parallel()`.
This commit is contained in:
parent
a2a6e79d21
commit
eb5b198205
1 changed files with 23 additions and 26 deletions
|
|
@ -56,34 +56,31 @@ func TestCrossArchDepsolve(t *testing.T) {
|
|||
|
||||
// NOTE: we can add RHEL, but don't make it hard requirement because it will fail outside of VPN
|
||||
for _, distroStruct := range []distro.Distro{fedora30.New(), fedora31.New(), fedora32.New()} {
|
||||
repos, err := rpmmd.LoadRepositories([]string{repoDir}, distroStruct.Name())
|
||||
assert.NoErrorf(t, err, "Failed to LoadRepositories %v", distroStruct.Name())
|
||||
if err != nil {
|
||||
// There is no point in running the tests without having repositories, but we can still run tests
|
||||
// for the remaining distros
|
||||
continue
|
||||
}
|
||||
for _, archStr := range distroStruct.ListArches() {
|
||||
arch, err := distroStruct.GetArch(archStr)
|
||||
assert.NoErrorf(t, err, "Failed to GetArch from %v structure", distroStruct.Name())
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
for _, imgTypeStr := range arch.ListImageTypes() {
|
||||
imgType, err := arch.GetImageType(imgTypeStr)
|
||||
assert.NoErrorf(t, err, "Failed to GetImageType for %v on %v", distroStruct.Name(), arch.Name())
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
t.Run(distroStruct.Name(), func(t *testing.T) {
|
||||
repos, err := rpmmd.LoadRepositories([]string{repoDir}, distroStruct.Name())
|
||||
require.NoErrorf(t, err, "Failed to LoadRepositories %v", distroStruct.Name())
|
||||
|
||||
buildPackages := imgType.BuildPackages()
|
||||
_, _, err = rpm.Depsolve(buildPackages, []string{}, repos[archStr], distroStruct.ModulePlatformID(), archStr)
|
||||
assert.NoErrorf(t, err, "Failed to Depsolve build packages for %v %v %v image", distroStruct.Name(), imgType.Name(), arch.Name())
|
||||
for _, archStr := range distroStruct.ListArches() {
|
||||
t.Run(archStr, func(t *testing.T) {
|
||||
arch, err := distroStruct.GetArch(archStr)
|
||||
require.NoError(t, err)
|
||||
|
||||
basePackagesInclude, basePackagesExclude := imgType.BasePackages()
|
||||
_, _, err = rpm.Depsolve(basePackagesInclude, basePackagesExclude, repos[archStr], distroStruct.ModulePlatformID(), archStr)
|
||||
assert.NoErrorf(t, err, "Failed to Depsolve base packages for %v %v %v image", distroStruct.Name(), imgType.Name(), arch.Name())
|
||||
for _, imgTypeStr := range arch.ListImageTypes() {
|
||||
t.Run(imgTypeStr, func(t *testing.T) {
|
||||
imgType, err := arch.GetImageType(imgTypeStr)
|
||||
require.NoError(t, err)
|
||||
|
||||
buildPackages := imgType.BuildPackages()
|
||||
_, _, err = rpm.Depsolve(buildPackages, []string{}, repos[archStr], distroStruct.ModulePlatformID(), archStr)
|
||||
assert.NoError(t, err)
|
||||
|
||||
basePackagesInclude, basePackagesExclude := imgType.BasePackages()
|
||||
_, _, err = rpm.Depsolve(basePackagesInclude, basePackagesExclude, repos[archStr], distroStruct.ModulePlatformID(), archStr)
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue