From b15f7887bf55c64f84e7401234a8c0c94ee7a976 Mon Sep 17 00:00:00 2001 From: Ondrej Ezr Date: Tue, 2 Jan 2024 19:50:38 +0100 Subject: [PATCH] test: weldr api module_hotfixes flag --- internal/client/blueprints_test.go | 79 ++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/internal/client/blueprints_test.go b/internal/client/blueprints_test.go index 8cfa9a7be4d..4ff2a9d5dff 100644 --- a/internal/client/blueprints_test.go +++ b/internal/client/blueprints_test.go @@ -14,6 +14,7 @@ import ( "encoding/json" "fmt" "os/exec" + "runtime" "sort" "strconv" "strings" @@ -1006,6 +1007,84 @@ func TestBlueprintDepsolveGlobsV0(t *testing.T) { assert.True(t, common.IsStringInSortedSlice(names, "tmux")) } +// depsolve a blueprint with package from 3rd party with module_hotfixes +func TestBlueprintDepsolveModuleHotfixesErrorV0(t *testing.T) { + // Depends on real packages, only run as an integration test + if testState.unitTest { + t.Skip() + } + var repo string + switch runtime.GOARCH { + case "amd64": + repo = "https://rpmrepo.osbuild.org/v2/mirror/public/el8/el8-x86_64-nginx-20231207" + case "arm64": + repo = "https://rpmrepo.osbuild.org/v2/mirror/public/el8/el8-aarch64-nginx-20231207" + } + bp := fmt.Sprintf(`{ + "name": "test-deps-blueprint-module-hotfixes-error-v0", + "description": "CheckBlueprintDepsolveModuleHotfixesErrorV0", + "version": "0.0.1", + "packages": [{"name": "nginx", "version": "*"}, + {"name": "nginx-module-njs", "version": "*"}], + "customizations": {"repositories": [ + {"id": "nginx", "module_hotfixes": false, + "baseurls": ["%s"], + "gpgcheck": false, "check_repo_gpg": false} + ]} + }`, repo) + + // Push a blueprint + resp, err := PostJSONBlueprintV0(testState.socket, bp) + require.NoError(t, err, "POST blueprint failed with a client error") + require.True(t, resp.Status, "POST blueprint failed: %#v", resp) + + // Depsolve the blueprint + deps, api, err := DepsolveBlueprintV0(testState.socket, "test-deps-blueprint-module-hotfixes-error-v0") + require.NoError(t, err, "Depsolve blueprint failed with a client error") + require.Nil(t, api, "DepsolveBlueprint failed: %#v", api) + require.Greater(t, len(deps.Errors), 0, "Errors occurred during depsolving") +} + +// depsolve a blueprint with package from 3rd party with module_hotfixes +func TestBlueprintDepsolveModuleHotfixesV0(t *testing.T) { + // Depends on real packages, only run as an integration test + if testState.unitTest { + t.Skip() + } + var repo string + switch runtime.GOARCH { + case "amd64": + repo = "https://rpmrepo.osbuild.org/v2/mirror/public/el8/el8-x86_64-nginx-20231207" + case "arm64": + repo = "https://rpmrepo.osbuild.org/v2/mirror/public/el8/el8-aarch64-nginx-20231207" + } + bp := fmt.Sprintf(`{ + "name": "test-deps-blueprint-module-hotfixes-v0", + "description": "CheckBlueprintDepsolveModuleHotfixesV0", + "version": "0.0.1", + "packages": [{"name": "nginx", "version": "*"}, + {"name": "nginx-module-njs", "version": "*"}], + "customizations": {"repositories": [ + {"id": "nginx", "module_hotfixes": true, + "baseurls": ["%s"], + "gpgcheck": false, "check_repo_gpg": false} + ]} + }`, repo) + + // Push a blueprint + resp, err := PostJSONBlueprintV0(testState.socket, bp) + require.NoError(t, err, "POST blueprint failed with a client error") + require.True(t, resp.Status, "POST blueprint failed: %#v", resp) + + // Depsolve the blueprint + deps, api, err := DepsolveBlueprintV0(testState.socket, "test-deps-blueprint-module-hotfixes-v0") + require.NoError(t, err, "Depsolve blueprint failed with a client error") + require.Nil(t, api, "DepsolveBlueprint failed: %#v", api) + t.Log(deps.Errors[0].Msg) + require.Equal(t, 0, len(deps.Errors), "Errors occurred during depsolving") + require.Greater(t, len(deps.Blueprints), 0, "No blueprint dependencies returned") +} + // depsolve a non-existent blueprint func TestNonBlueprintDepsolveV0(t *testing.T) { resp, api, err := DepsolveBlueprintV0(testState.socket, "test-deps-non-blueprint-v0")