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 between diag.ErrorDiagnostic/diag.WarningDiagnostic and diag.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 an Equal() method that handles severity, summary, and detail equality, so all that is necessary would be implementing an Equal() method on the diag.Diagnostics type alias as well.
References
Not sure if this would affect #217.
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.WarningDiagnosticanddiag.withPath) in some cases are not possible to test outside the framework (internal/reflect.DiagIntoIncompatibleType).Attempted Solutions
Using go-cmp with
diag.Diagnosticstypes and skipping unit testing where problematic.Proposal
The
diag.Diagnosticinterface already requires anEqual()method that handles severity, summary, and detail equality, so all that is necessary would be implementing anEqual()method on thediag.Diagnosticstype alias as well.References
Not sure if this would affect #217.