forked from mirrors/homebox
fix: export child relationships (#385)
* tidy * ensure export contains locations path * update pnpm lock file * fix swagger stuff * code gen * fix linter issue * fix reverse order bug in test
This commit is contained in:
parent
6a853c07a0
commit
ced5aef6d1
17 changed files with 1965 additions and 1686 deletions
|
@ -146,6 +146,34 @@ func TestItemRepository_TreeQuery(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestLocationRepository_PathForLoc(t *testing.T) {
|
||||
locs := useLocations(t, 3)
|
||||
|
||||
// Set relations 3 -> 2 -> 1
|
||||
for i := 0; i < 2; i++ {
|
||||
_, err := tRepos.Locations.UpdateByGroup(context.Background(), tGroup.ID, locs[i].ID, LocationUpdate{
|
||||
ID: locs[i].ID,
|
||||
ParentID: locs[i+1].ID,
|
||||
Name: locs[i].Name,
|
||||
Description: locs[i].Description,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
last := locs[0]
|
||||
|
||||
path, err := tRepos.Locations.PathForLoc(context.Background(), tGroup.ID, last.ID)
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 3, len(path))
|
||||
|
||||
// Check path and order
|
||||
for i, loc := range path {
|
||||
assert.Equal(t, locs[2-i].ID, loc.ID)
|
||||
assert.Equal(t, locs[2-i].Name, loc.Name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConvertLocationsToTree(t *testing.T) {
|
||||
uuid1, uuid2, uuid3, uuid4 := uuid.New(), uuid.New(), uuid.New(), uuid.New()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue