You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
In equivalence_test.go, there's a fake implementation of MetricService. It implements exactly the methods of that service as of now. Thus, if new methods are introduced (or in the case of the mono-repo, there are additional internal-only methods), this causes a compilation break, even if those methods are never exercised.
The protocol compiler will produce an UnimplementedMetricServiceServer which provides dummy methods that return NYI errors. If this is used as a field of the fake, e.g.,
type fakeMetricsServer struct {
monitoringpb.UnimplementedMetricServiceServer
…
then if methods are introduced, the fake will still compile and the new methods will just return errors. In this particular case, all the methods unused by the test could just be removed, since it will still fulfill the interface.
The text was updated successfully, but these errors were encountered:
Appears that this isn't rendered as a part of genproto, so perhaps use of just the raw MetricServiceServer interface would do. It won't nicely error, but just panic if a nil method is called.
Capstan
changed the title
use Unimplemented*Server interfaces in implementations of fake*Server
use *Server interfaces in implementations of fake*Server
Jul 5, 2019
Capstan
added a commit
to Capstan/opencensus-go-exporter-stackdriver
that referenced
this issue
Jul 5, 2019
* Use MetricServiceServer in fakeMetricService.
Fixes#167.
* Remove uncalled fake methods and type assertion.
Given that the fakeMetricService includes the MetricServiceServer interface, it necessarily implements the interface, even if some of the methods are nil and would panic if called. Uncalled methods are removed.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
In equivalence_test.go, there's a fake implementation of
MetricService
. It implements exactly the methods of that service as of now. Thus, if new methods are introduced (or in the case of the mono-repo, there are additional internal-only methods), this causes a compilation break, even if those methods are never exercised.The protocol compiler will produce an
UnimplementedMetricServiceServer
which provides dummy methods that return NYI errors. If this is used as a field of the fake, e.g.,then if methods are introduced, the fake will still compile and the new methods will just return errors. In this particular case, all the methods unused by the test could just be removed, since it will still fulfill the interface.
The text was updated successfully, but these errors were encountered: