Skip to content

Commit

Permalink
Add reference for ComplianceError in String() message.
Browse files Browse the repository at this point in the history
  • Loading branch information
wenovus committed Jun 6, 2023
1 parent eee44f8 commit feaf522
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ygnmi/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions ygnmi/unmarshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package ygnmi

import (
"fmt"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit feaf522

Please sign in to comment.