Tests: remove fedoratest and replace it with test_distro

fedoratest was yet another dummy distribution used by unit tests. After
the rework of test_distro, there is no reason to not use it as the only
distro implementation for testing purposes.

Remove fedoratest distro and replace it with test_distro in all affected
tests.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
Tomas Hozza 2021-05-05 11:30:00 +02:00 committed by Ondřej Budai
parent e5dd45b71c
commit f7f064274a
11 changed files with 151 additions and 270 deletions

View file

@ -1,13 +1,14 @@
package store
import (
"fmt"
"time"
"github.com/google/uuid"
"github.com/osbuild/osbuild-composer/internal/blueprint"
"github.com/osbuild/osbuild-composer/internal/common"
"github.com/osbuild/osbuild-composer/internal/distro"
"github.com/osbuild/osbuild-composer/internal/distro/fedoratest"
"github.com/osbuild/osbuild-composer/internal/distro/test_distro"
"github.com/osbuild/osbuild-composer/internal/rpmmd"
"github.com/osbuild/osbuild-composer/internal/target"
)
@ -49,18 +50,18 @@ func FixtureBase() *Store {
},
}
d := fedoratest.New()
arch, err := d.GetArch("x86_64")
d := test_distro.New()
arch, err := d.GetArch(test_distro.TestArchName)
if err != nil {
panic("invalid architecture x86_64 for fedoratest")
panic(fmt.Sprintf("failed to get architecture %s for a test distro: %v", test_distro.TestArchName, err))
}
imgType, err := arch.GetImageType("qcow2")
imgType, err := arch.GetImageType(test_distro.TestImageTypeName)
if err != nil {
panic("invalid image type qcow2 for x86_64 @ fedoratest")
panic(fmt.Sprintf("failed to get image type %s for a test distro architecture: %v", test_distro.TestImageTypeName, err))
}
manifest, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, 0)
if err != nil {
panic("could not create manifest")
panic(fmt.Sprintf("failed to create a manifest: %v", err))
}
s := New(nil, arch, nil)
@ -70,13 +71,13 @@ func FixtureBase() *Store {
Epoch: 0,
Version: "2.11.2",
Release: "1.fc35",
Arch: "x86_64",
Arch: test_distro.TestArchName,
}, {
Name: "test2",
Epoch: 3,
Version: "4.2.2",
Release: "1.fc35",
Arch: "x86_64",
Arch: test_distro.TestArchName,
}}
s.blueprints[bName] = b
@ -184,18 +185,18 @@ func FixtureFinished() *Store {
},
}
d := fedoratest.New()
arch, err := d.GetArch("x86_64")
d := test_distro.New()
arch, err := d.GetArch(test_distro.TestArchName)
if err != nil {
panic("invalid architecture x86_64 for fedoratest")
panic(fmt.Sprintf("failed to get architecture %s for a test distro: %v", test_distro.TestArchName, err))
}
imgType, err := arch.GetImageType("qcow2")
imgType, err := arch.GetImageType(test_distro.TestImageTypeName)
if err != nil {
panic("invalid image type qcow2 for x86_64 @ fedoratest")
panic(fmt.Sprintf("failed to get image type %s for a test distro architecture: %v", test_distro.TestImageTypeName, err))
}
manifest, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, 0)
if err != nil {
panic("could not create manifest")
panic(fmt.Sprintf("failed to create a manifest: %v", err))
}
s := New(nil, arch, nil)
@ -205,13 +206,13 @@ func FixtureFinished() *Store {
Epoch: 0,
Version: "2.11.2",
Release: "1.fc35",
Arch: "x86_64",
Arch: test_distro.TestArchName,
}, {
Name: "test2",
Epoch: 3,
Version: "4.2.2",
Release: "1.fc35",
Arch: "x86_64",
Arch: test_distro.TestArchName,
}}
s.blueprints[bName] = b
@ -280,11 +281,12 @@ func FixtureEmpty() *Store {
Customizations: nil,
}
d := fedoratest.New()
arch, err := d.GetArch("x86_64")
d := test_distro.New()
arch, err := d.GetArch(test_distro.TestArchName)
if err != nil {
panic("invalid architecture x86_64 for fedoratest")
panic(fmt.Sprintf("failed to get architecture %s for a test distro: %v", test_distro.TestArchName, err))
}
s := New(nil, arch, nil)
s.blueprints[bName] = b

View file

@ -2,6 +2,7 @@ package store
import (
"encoding/json"
"fmt"
"io/ioutil"
"path/filepath"
"reflect"
@ -13,7 +14,6 @@ import (
"github.com/osbuild/osbuild-composer/internal/common"
"github.com/osbuild/osbuild-composer/internal/distro"
"github.com/osbuild/osbuild-composer/internal/distro/fedora32"
"github.com/osbuild/osbuild-composer/internal/distro/fedoratest"
"github.com/osbuild/osbuild-composer/internal/distro/test_distro"
"github.com/osbuild/osbuild-composer/internal/rpmmd"
"github.com/osbuild/osbuild-composer/internal/target"
@ -113,10 +113,10 @@ func Test_imageTypeFromCompatString(t *testing.T) {
}
func TestMarshalEmpty(t *testing.T) {
d := fedoratest.New()
arch, err := d.GetArch("x86_64")
d := test_distro.New()
arch, err := d.GetArch(test_distro.TestArchName)
if err != nil {
panic("invalid architecture x86_64 for fedoratest")
panic(fmt.Sprintf("failed to get architecture %s for a test distro: %v", test_distro.TestArchName, err))
}
store1 := FixtureEmpty()
storeV0 := store1.toStoreV0()
@ -127,10 +127,10 @@ func TestMarshalEmpty(t *testing.T) {
}
func TestMarshalFinished(t *testing.T) {
d := fedoratest.New()
arch, err := d.GetArch("x86_64")
d := test_distro.New()
arch, err := d.GetArch(test_distro.TestArchName)
if err != nil {
panic("invalid architecture x86_64 for fedoratest")
panic(fmt.Sprintf("failed to get architecture %s for a test distro: %v", test_distro.TestArchName, err))
}
store1 := FixtureFinished()
storeV0 := store1.toStoreV0()