From feaf52235ad6550e98f0bfe6fa4f4de733ec8086 Mon Sep 17 00:00:00 2001 From: wenovus Date: Tue, 6 Jun 2023 12:16:32 -0700 Subject: [PATCH] Add reference for ComplianceError in String() message. --- ygnmi/unmarshal.go | 2 +- ygnmi/unmarshal_test.go | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ygnmi/unmarshal.go b/ygnmi/unmarshal.go index 98e6be8..e280fcc 100644 --- a/ygnmi/unmarshal.go +++ b/ygnmi/unmarshal.go @@ -78,7 +78,7 @@ func (c *ComplianceErrors) String() string { return "" } var b strings.Builder - b.WriteString("Noncompliance Errors by category:") + b.WriteString("Noncompliance Errors by category (for explanation see https://github.com/openconfig/ygnmi#noncompliance-errors):") b.WriteString("\nPath Noncompliance Errors:") if len(c.PathErrors) != 0 { for _, e := range c.PathErrors { diff --git a/ygnmi/unmarshal_test.go b/ygnmi/unmarshal_test.go index 8c8cd9c..13f36b2 100644 --- a/ygnmi/unmarshal_test.go +++ b/ygnmi/unmarshal_test.go @@ -15,6 +15,8 @@ package ygnmi import ( + "fmt" + "strings" "testing" "time" @@ -952,6 +954,11 @@ func TestUnmarshal(t *testing.T) { pathErrs = complianceErrs.PathErrors typeErrs = complianceErrs.TypeErrors validateErrs = complianceErrs.ValidateErrors + // Validate documentation on error + if !strings.Contains(complianceErrs.String(), "https://github.com/openconfig/ygnmi#noncompliance-errors") { + fmt.Println(complianceErrs.String()) + t.Errorf("ComplianceError String() didn't contain expected reference to documentation.") + } } if len(pathErrs) > 1 { t.Fatalf("unmarshal: got more than one path unmarshal error: %v", pathErrs)