Skip to content

Commit

Permalink
test: weldr api module_hotfixes flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ezr-ondrej committed Jan 3, 2024
1 parent 623e761 commit 110b4dd
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions internal/client/blueprints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,70 @@ 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()
}
bp := `{
"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": ["https://rpmrepo.osbuild.org/v2/mirror/public/el8/el8-x86_64-nginx-20231207"],
"gpgcheck": false, "check_repo_gpg": false}
]}
}`

// 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()
}
bp := `{
"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": ["https://rpmrepo.osbuild.org/v2/mirror/public/el8/el8-x86_64-nginx-20231207"],
"gpgcheck": false, "check_repo_gpg": false}
]}
}`

// 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")
Expand Down

0 comments on commit 110b4dd

Please sign in to comment.