diag: Consider Equal() method for Diagnostics #397
Labels
diags
Issues and pull requests about our diagnostics abstraction.
enhancement
New feature or request
Milestone
Module version
Use-cases
Downstream code may desire to do equality checking of
diag.Diagnostics
, such as unit testing responses from various framework functionality. In particular,Most Go modules that implement checking of this sort, such as https://pkg.go.dev/github.com/google/go-cmp, will prefer an
Equal()
method on a Go type if it exists. Otherwise they will fallback to other methods, such as type and field inspection, which are more difficult to manage (e.g. differences betweendiag.ErrorDiagnostic
/diag.WarningDiagnostic
anddiag.withPath
) in some cases are not possible to test outside the framework (internal/reflect.DiagIntoIncompatibleType
).Attempted Solutions
Using go-cmp with
diag.Diagnostics
types and skipping unit testing where problematic.Proposal
The
diag.Diagnostic
interface already requires anEqual()
method that handles severity, summary, and detail equality, so all that is necessary would be implementing anEqual()
method on thediag.Diagnostics
type alias as well.References
Not sure if this would affect #217.
The text was updated successfully, but these errors were encountered: