From 73ab18a501cec553a7e1a13e98d58344f8d2c9e4 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Fri, 5 May 2023 15:06:43 -0700 Subject: [PATCH] tests: Add a test for blueprint package name globs This tests to make sure that package name globs are working during integration test runs. dnf supports this, and users have been using it, so testing to make sure it keeps working is important. --- internal/client/blueprints_test.go | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/internal/client/blueprints_test.go b/internal/client/blueprints_test.go index d53d1552c..135e52b9b 100644 --- a/internal/client/blueprints_test.go +++ b/internal/client/blueprints_test.go @@ -966,6 +966,43 @@ func TestMultilibBlueprintDepsolveV0(t *testing.T) { } } +// depsolve a blueprint with package name glob +func TestBlueprintDepsolveGlobsV0(t *testing.T) { + // Depends on real packages, only run as an integration test + if testState.unitTest { + t.Skip() + } + bp := `{ + "name": "test-deps-blueprint-globs-v0", + "description": "CheckBlueprintDepsolveGlobsV0", + "version": "0.0.1", + "packages": [{"name": "tmux", "version": "*"}, + {"name": "openssh-*", "version": "*"}] + }` + + // 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-globs-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.Blueprints), 0, "No blueprint dependencies returned") + require.Greater(t, len(deps.Blueprints[0].Dependencies), 2, "Not enough dependencies returned") + + // Did it include tmux? Did it include openssh-clients and openssh-server? + var names []string + for _, d := range deps.Blueprints[0].Dependencies { + names = append(names, d.Name) + } + sort.Strings(names) + assert.True(t, common.IsStringInSortedSlice(names, "openssh-clients")) + assert.True(t, common.IsStringInSortedSlice(names, "openssh-server")) + assert.True(t, common.IsStringInSortedSlice(names, "tmux")) +} + // depsolve a non-existent blueprint func TestNonBlueprintDepsolveV0(t *testing.T) { resp, api, err := DepsolveBlueprintV0(testState.socket, "test-deps-non-blueprint-v0")