-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Add missing Targets to ui.target.order after seeding (#536)
This also adds some convenience methods to the `Setting` model to make reading and updating their values somewhat less tedious. Fixes #505 --------- Signed-off-by: Sam Lucidi <[email protected]>
- Loading branch information
Showing
3 changed files
with
121 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package seed | ||
|
||
import ( | ||
"github.com/onsi/gomega" | ||
"testing" | ||
) | ||
|
||
func TestMerge(t *testing.T) { | ||
g := gomega.NewWithT(t) | ||
|
||
// the seed contains 10 targets in a given order, 3 of which are new | ||
seedOrder := []uint{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} | ||
// the user has set up a custom order for the 7 targets that already exist in the db | ||
userOrder := []uint{6, 9, 5, 4, 1, 3, 2} | ||
// the DB in total has 13 targets including the 3 newly seeded ones and 3 that were pre-existing | ||
// in the DB not not represented in the ordering due to a previous bug. | ||
allIds := []uint{11, 12, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10} | ||
// we expect the newly added targets to be woven into the user's custom ordering, with any targets | ||
// that had previously been dropped on the floor being added to the end of the ordering. | ||
expectedOrder := []uint{6, 7, 8, 9, 10, 5, 4, 1, 3, 2, 11, 12, 13} | ||
|
||
mergedOrder := merge(userOrder, seedOrder, allIds) | ||
g.Expect(mergedOrder).To(gomega.Equal(expectedOrder)) | ||
} |