distro: bring back TestImageType_PackageSetsChains()
This test was removed because package sets in chains are no longer visible in the map returned from ImageType.PackageSets(). Bringing back the test now to ensure that: 1. All package set names defined in the keys returned from the PackageSets() map match the keys returned from the PackageSetsChains() map. 2. All package sets defined in the package set chains are defined for the image type. This is tested by the function PackageSets() function itself, which should never panic.
This commit is contained in:
parent
ce1474e364
commit
d3dc4eba39
1 changed files with 27 additions and 0 deletions
|
|
@ -1,11 +1,14 @@
|
|||
package distro_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/distro_test_common"
|
||||
"github.com/osbuild/osbuild-composer/internal/distroregistry"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
|
@ -99,3 +102,27 @@ func TestDistro_Version(t *testing.T) {
|
|||
require.Error(err, "Invalid manifest did not return an error")
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that all package sets defined in the package set chains are defined for the image type
|
||||
func TestImageType_PackageSetsChains(t *testing.T) {
|
||||
distros := distroregistry.NewDefault()
|
||||
for _, distroName := range distros.List() {
|
||||
d := distros.GetDistro(distroName)
|
||||
for _, archName := range d.ListArches() {
|
||||
arch, err := d.GetArch(archName)
|
||||
require.Nil(t, err)
|
||||
for _, imageTypeName := range arch.ListImageTypes() {
|
||||
t.Run(fmt.Sprintf("%s/%s/%s", distroName, archName, imageTypeName), func(t *testing.T) {
|
||||
imageType, err := arch.GetImageType(imageTypeName)
|
||||
require.Nil(t, err)
|
||||
|
||||
imagePkgSets := imageType.PackageSets(blueprint.Blueprint{}, nil)
|
||||
for packageSetName := range imageType.PackageSetsChains() {
|
||||
_, ok := imagePkgSets[packageSetName]
|
||||
assert.Truef(t, ok, "package set %q defined in a package set chain is not present in the image package sets", packageSetName)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue