From 58ad4ff85bf4574e53c4491c37581a6493b1d132 Mon Sep 17 00:00:00 2001 From: Egor Kovetskiy Date: Tue, 2 Feb 2021 08:05:23 +0300 Subject: [PATCH] show what ancestors were expected --- pkg/mark/ancestry.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/mark/ancestry.go b/pkg/mark/ancestry.go index 105b0bf..71df174 100644 --- a/pkg/mark/ancestry.go +++ b/pkg/mark/ancestry.go @@ -109,11 +109,15 @@ func ValidateAncestry( } if len(page.Ancestors) < len(ancestry) { - return nil, fmt.Errorf( - "page %q has fewer parents than specified: %s", - page.Title, - strings.Join(ancestry, ` > `), - ) + actual := []string{} + for _, ancestor := range page.Ancestors { + actual = append(actual, ancestor.Title) + } + + return nil, karma.Describe("title", page.Title). + Describe("actual", strings.Join(actual, " > ")). + Describe("expected", strings.Join(ancestry, ">")). + Format(nil, "the page has fewer parents than expected") } for _, parent := range ancestry[:len(ancestry)-1] {