Fix /blueprints/freeze results
The dependencies are not sorted, so depending on what order they were returned in the freeze route would or would not return the correct results (exhibited by the version being the original glob instead of the EVRA). This also fixes the tests so that the depsolve results are slightly unsorted by adding a dep-package3 to the start of the list.
This commit is contained in:
parent
defc34b7f0
commit
56e764a11d
3 changed files with 18 additions and 6 deletions
|
|
@ -155,6 +155,13 @@ func createBaseStoreFixture() *store.Store {
|
|||
|
||||
func createBaseDepsolveFixture() []rpmmd.PackageSpec {
|
||||
return []rpmmd.PackageSpec{
|
||||
{
|
||||
Name: "dep-package3",
|
||||
Epoch: 0,
|
||||
Version: "3.0.3",
|
||||
Release: "1.fc30",
|
||||
Arch: "x86_64",
|
||||
},
|
||||
{
|
||||
Name: "dep-package1",
|
||||
Epoch: 0,
|
||||
|
|
|
|||
|
|
@ -898,8 +898,13 @@ func (api *API) blueprintsFreezeHandler(writer http.ResponseWriter, request *htt
|
|||
errors = append(errors, rerr)
|
||||
break
|
||||
}
|
||||
// Sort dependencies by Name (names should be unique so no need to sort by EVRA)
|
||||
sort.Slice(dependencies, func(i, j int) bool {
|
||||
return dependencies[i].Name < dependencies[j].Name
|
||||
})
|
||||
|
||||
for pkgIndex, pkg := range blueprint.Packages {
|
||||
// sort.Search requires the input to be sorted
|
||||
i := sort.Search(len(dependencies), func(i int) bool {
|
||||
return dependencies[i].Name >= pkg.Name
|
||||
})
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue