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:
parent
e5dd45b71c
commit
f7f064274a
11 changed files with 151 additions and 270 deletions
|
|
@ -21,6 +21,7 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
|
@ -40,12 +41,12 @@ func TestComposeTypesV0(t *testing.T) {
|
|||
require.Greater(t, len(composeTypes), 0)
|
||||
var found bool
|
||||
for _, t := range composeTypes {
|
||||
if t.Name == "qcow2" && t.Enabled == true {
|
||||
if t.Name == testState.imageTypeName && t.Enabled == true {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
require.True(t, found, "qcow2 not in list of compose types: %#v", composeTypes)
|
||||
require.True(t, found, "%s not in list of compose types: %#v", testState.imageTypeName, composeTypes)
|
||||
}
|
||||
|
||||
// Test compose with invalid type fails
|
||||
|
|
@ -76,11 +77,11 @@ func TestComposeInvalidTypeV0(t *testing.T) {
|
|||
|
||||
// Test compose for unknown blueprint fails
|
||||
func TestComposeInvalidBlueprintV0(t *testing.T) {
|
||||
compose := `{
|
||||
compose := fmt.Sprintf(`{
|
||||
"blueprint_name": "test-invalid-bp-compose-v0",
|
||||
"compose_type": "qcow2",
|
||||
"compose_type": "%s",
|
||||
"branch": "master"
|
||||
}`
|
||||
}`, testState.imageTypeName)
|
||||
resp, err := PostComposeV0(testState.socket, compose)
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.NotNil(t, resp)
|
||||
|
|
@ -91,11 +92,11 @@ func TestComposeInvalidBlueprintV0(t *testing.T) {
|
|||
|
||||
// Test compose for empty blueprint fails
|
||||
func TestComposeEmptyBlueprintV0(t *testing.T) {
|
||||
compose := `{
|
||||
compose := fmt.Sprintf(`{
|
||||
"blueprint_name": "",
|
||||
"compose_type": "qcow2",
|
||||
"compose_type": "%s",
|
||||
"branch": "master"
|
||||
}`
|
||||
}`, testState.imageTypeName)
|
||||
resp, err := PostComposeV0(testState.socket, compose)
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.NotNil(t, resp)
|
||||
|
|
@ -106,11 +107,11 @@ func TestComposeEmptyBlueprintV0(t *testing.T) {
|
|||
|
||||
// Test compose for blueprint with invalid characters fails
|
||||
func TestComposeInvalidCharsBlueprintV0(t *testing.T) {
|
||||
compose := `{
|
||||
compose := fmt.Sprintf(`{
|
||||
"blueprint_name": "I w𝒊ll 𝟉ο𝘁 𝛠a𝔰ꜱ 𝘁𝒉𝝸𝚜",
|
||||
"compose_type": "qcow2",
|
||||
"compose_type": "%s",
|
||||
"branch": "master"
|
||||
}`
|
||||
}`, testState.imageTypeName)
|
||||
resp, err := PostComposeV0(testState.socket, compose)
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.NotNil(t, resp)
|
||||
|
|
@ -283,11 +284,11 @@ func TestFailedComposeV0(t *testing.T) {
|
|||
require.NoError(t, err, "failed with a client error")
|
||||
require.True(t, resp.Status, "POST failed: %#v", resp)
|
||||
|
||||
compose := `{
|
||||
compose := fmt.Sprintf(`{
|
||||
"blueprint_name": "test-failed-compose-v0",
|
||||
"compose_type": "qcow2",
|
||||
"compose_type": "%s",
|
||||
"branch": "master"
|
||||
}`
|
||||
}`, testState.imageTypeName)
|
||||
// Create a failed test compose
|
||||
body, resp, err := PostJSON(testState.socket, "/api/v1/compose?test=1", compose)
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
|
|
@ -378,11 +379,11 @@ func TestFinishedComposeV0(t *testing.T) {
|
|||
require.NoError(t, err, "failed with a client error")
|
||||
require.True(t, resp.Status, "POST failed: %#v", resp)
|
||||
|
||||
compose := `{
|
||||
compose := fmt.Sprintf(`{
|
||||
"blueprint_name": "test-finished-compose-v0",
|
||||
"compose_type": "qcow2",
|
||||
"compose_type": "%s",
|
||||
"branch": "master"
|
||||
}`
|
||||
}`, testState.imageTypeName)
|
||||
// Create a finished test compose
|
||||
body, resp, err := PostJSON(testState.socket, "/api/v1/compose?test=2", compose)
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ var testState *TestState
|
|||
// Also makes sure there is a running server to test against
|
||||
func executeTests(m *testing.M) int {
|
||||
var err error
|
||||
testState, err = setUpTestState("/run/weldr/api.socket", false)
|
||||
|
||||
testState, err = setUpTestState("/run/weldr/api.socket", "qcow2", false)
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: Test setup failed: %s\n", err)
|
||||
panic(err)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import (
|
|||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/fedoratest"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/test_distro"
|
||||
rpmmd_mock "github.com/osbuild/osbuild-composer/internal/mocks/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/weldr"
|
||||
|
|
@ -44,8 +44,8 @@ func executeTests(m *testing.M) int {
|
|||
}
|
||||
fixture := rpmmd_mock.BaseFixture(path.Join(tmpdir, "/jobs"))
|
||||
rpm := rpmmd_mock.NewRPMMDMock(fixture)
|
||||
distro := fedoratest.New()
|
||||
arch, err := distro.GetArch("x86_64")
|
||||
distro := test_distro.New()
|
||||
arch, err := distro.GetArch(test_distro.TestArchName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
@ -62,7 +62,7 @@ func executeTests(m *testing.M) int {
|
|||
}
|
||||
}()
|
||||
|
||||
testState, err = setUpTestState(socketPath, true)
|
||||
testState, err = setUpTestState(socketPath, test_distro.TestImageTypeName, true)
|
||||
if err != nil {
|
||||
log.Fatalf("ERROR: Test setup failed: %s\n", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,10 +14,11 @@ import (
|
|||
)
|
||||
|
||||
type TestState struct {
|
||||
socket *http.Client
|
||||
apiVersion int
|
||||
repoDir string
|
||||
unitTest bool
|
||||
socket *http.Client
|
||||
apiVersion int
|
||||
repoDir string
|
||||
unitTest bool
|
||||
imageTypeName string
|
||||
}
|
||||
|
||||
// isStringInSlice returns true if the string is present, false if not
|
||||
|
|
@ -31,8 +32,8 @@ func isStringInSlice(slice []string, s string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func setUpTestState(socketPath string, unitTest bool) (*TestState, error) {
|
||||
state := TestState{unitTest: unitTest}
|
||||
func setUpTestState(socketPath string, imageTypeName string, unitTest bool) (*TestState, error) {
|
||||
state := TestState{imageTypeName: imageTypeName, unitTest: unitTest}
|
||||
|
||||
state.socket = &http.Client{
|
||||
Transport: &http.Transport{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue