diff --git a/common/general/general.go b/common/general/general.go index be39339..2ff9ccb 100644 --- a/common/general/general.go +++ b/common/general/general.go @@ -357,9 +357,19 @@ func VerifyContractWithSchema(contract string) (bool, error) { return false, fmt.Errorf("failed to validate contract - %v", err) } - for _, err := range report.Errors() { - fmt.Printf("- %s\n", err) - } + result := report.Valid() + + if result { + return true, nil + } else { + var consolidatedErrors strings.Builder + for i, err := range report.Errors() { + if i > 0 { + consolidatedErrors.WriteString(", ") + } + consolidatedErrors.WriteString(err.String()) + } - return report.Valid(), nil + return report.Valid(), fmt.Errorf("validation failed - %s", consolidatedErrors.String()) + } } diff --git a/common/general/general_test.go b/common/general/general_test.go index 9a8664f..73d6315 100644 --- a/common/general/general_test.go +++ b/common/general/general_test.go @@ -269,5 +269,5 @@ func TestVerifyContractWithSchema(t *testing.T) { t.Errorf("schema verification failed - %v", err) } - fmt.Println(result) + assert.True(t, result) }