Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

fix: broken test

Matthew Kilgore60c0bca75685
diff --git a/backend/internal/data/repo/repo_tags.go b/backend/internal/data/repo/repo_tags.go
index 10403609..75b3683d 100644
--- a/backend/internal/data/repo/repo_tags.go
+++ b/backend/internal/data/repo/repo_tags.go
@@ -70,9 +70,14 @@ type (
)
func mapTagSummary(tag *ent.Tag) TagSummary {
+ parentID := uuid.Nil
+ if tag.Edges.Parent != nil {
+ parentID = tag.Edges.Parent.ID
+ }
+
return TagSummary{
ID: tag.ID,
- ParentID: lo.Ternary(tag.Edges.Parent != nil, tag.Edges.Parent.ID, uuid.Nil),
+ ParentID: parentID,
Name: tag.Name,
Description: tag.Description,
Color: tag.Color,
@@ -97,11 +102,14 @@ func mapTagOut(tag *ent.Tag) TagOut {
func() *TagSummary { return nil },
)
- children := lo.Map(tag.Edges.Children, func(c *ent.Tag, _ int) TagSummary {
- summary := mapTagSummary(c)
- summary.ParentID = tag.ID
- return summary
- })
+ children := []TagSummary{}
+ if tag.Edges.Children != nil {
+ children = lo.Map(tag.Edges.Children, func(c *ent.Tag, _ int) TagSummary {
+ summary := mapTagSummary(c)
+ summary.ParentID = tag.ID
+ return summary
+ })
+ }
return TagOut{
TagSummary: mapTagSummary(tag),