distro_test: add test that covers BuildPackages

The main reason here is not to make sure we have the right set of build
packages, but rather to make sure the pointer hierarchy (distro->arch->
image type) works as expected.
This commit is contained in:
Martin Sehnoutka 2020-03-27 20:44:23 +01:00 committed by Tom Gundersen
parent 91f572e961
commit db4b6e71ed
3 changed files with 135 additions and 0 deletions

View file

@ -2,6 +2,7 @@ package fedora30_test
import (
"github.com/osbuild/osbuild-composer/internal/distro/fedora30"
"reflect"
"testing"
)
@ -92,3 +93,47 @@ func TestFilenameFromType(t *testing.T) {
})
}
}
func TestImageType_BuildPackages(t *testing.T) {
x8664BuildPackages := []string{
"dnf",
"dosfstools",
"e2fsprogs",
"grub2-pc",
"policycoreutils",
"qemu-img",
"systemd",
"tar",
"xz",
}
aarch64BuildPackages := []string{
"dnf",
"dosfstools",
"e2fsprogs",
"policycoreutils",
"qemu-img",
"systemd",
"tar",
"xz",
}
buildPackages := map[string][]string{
"x86_64": x8664BuildPackages,
"aarch64": aarch64BuildPackages,
}
d := fedora30.New()
for _, archLabel := range d.ListArchs() {
archStruct, err := d.GetArch(archLabel)
if err != nil {
t.Errorf("d.GetArch(%v) returned err = %v; expected nil", archLabel, err)
continue
}
for _, itLabel := range archStruct.ListImageTypes() {
itStruct, err := archStruct.GetImageType(itLabel)
if err != nil {
t.Errorf("d.GetArch(%v) returned err = %v; expected nil", archLabel, err)
continue
}
reflect.DeepEqual(itStruct.BuildPackages(), buildPackages[archLabel])
}
}
}

View file

@ -2,6 +2,7 @@ package fedora31_test
import (
"github.com/osbuild/osbuild-composer/internal/distro/fedora31"
"reflect"
"testing"
)
@ -92,3 +93,47 @@ func TestFilenameFromType(t *testing.T) {
})
}
}
func TestImageType_BuildPackages(t *testing.T) {
x8664BuildPackages := []string{
"dnf",
"dosfstools",
"e2fsprogs",
"grub2-pc",
"policycoreutils",
"qemu-img",
"systemd",
"tar",
"xz",
}
aarch64BuildPackages := []string{
"dnf",
"dosfstools",
"e2fsprogs",
"policycoreutils",
"qemu-img",
"systemd",
"tar",
"xz",
}
buildPackages := map[string][]string{
"x86_64": x8664BuildPackages,
"aarch64": aarch64BuildPackages,
}
d := fedora31.New()
for _, archLabel := range d.ListArchs() {
archStruct, err := d.GetArch(archLabel)
if err != nil {
t.Errorf("d.GetArch(%v) returned err = %v; expected nil", archLabel, err)
continue
}
for _, itLabel := range archStruct.ListImageTypes() {
itStruct, err := archStruct.GetImageType(itLabel)
if err != nil {
t.Errorf("d.GetArch(%v) returned err = %v; expected nil", archLabel, err)
continue
}
reflect.DeepEqual(itStruct.BuildPackages(), buildPackages[archLabel])
}
}
}

View file

@ -2,6 +2,7 @@ package fedora32_test
import (
"github.com/osbuild/osbuild-composer/internal/distro/fedora32"
"reflect"
"testing"
)
@ -92,3 +93,47 @@ func TestFilenameFromType(t *testing.T) {
})
}
}
func TestImageType_BuildPackages(t *testing.T) {
x8664BuildPackages := []string{
"dnf",
"dosfstools",
"e2fsprogs",
"grub2-pc",
"policycoreutils",
"qemu-img",
"systemd",
"tar",
"xz",
}
aarch64BuildPackages := []string{
"dnf",
"dosfstools",
"e2fsprogs",
"policycoreutils",
"qemu-img",
"systemd",
"tar",
"xz",
}
buildPackages := map[string][]string{
"x86_64": x8664BuildPackages,
"aarch64": aarch64BuildPackages,
}
d := fedora32.New()
for _, archLabel := range d.ListArchs() {
archStruct, err := d.GetArch(archLabel)
if err != nil {
t.Errorf("d.GetArch(%v) returned err = %v; expected nil", archLabel, err)
continue
}
for _, itLabel := range archStruct.ListImageTypes() {
itStruct, err := archStruct.GetImageType(itLabel)
if err != nil {
t.Errorf("d.GetArch(%v) returned err = %v; expected nil", archLabel, err)
continue
}
reflect.DeepEqual(itStruct.BuildPackages(), buildPackages[archLabel])
}
}
}