Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
Use MetricServiceServer in fakeMetricService. (#168)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Capstan authored and songy23 committed Jul 16, 2019
1 parent 1aade25 commit 655917a
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions equivalence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/golang/protobuf/ptypes/empty"
timestamp "github.com/golang/protobuf/ptypes/timestamp"
googlemetricpb "google.golang.org/genproto/googleapis/api/metric"
monitoredrespb "google.golang.org/genproto/googleapis/api/monitoredres"
monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
)

Expand Down Expand Up @@ -363,6 +362,7 @@ func TestEquivalenceStatsVsMetricsUploads(t *testing.T) {
}

type fakeMetricsServer struct {
monitoringpb.MetricServiceServer
mu sync.RWMutex
stackdriverTimeSeries []*monitoringpb.CreateTimeSeriesRequest
stackdriverMetricDescriptors []*monitoringpb.CreateMetricDescriptorRequest
Expand Down Expand Up @@ -417,12 +417,6 @@ func (server *fakeMetricsServer) resetStackdriverMetricDescriptors() {
server.mu.Unlock()
}

var _ monitoringpb.MetricServiceServer = (*fakeMetricsServer)(nil)

func (server *fakeMetricsServer) GetMetricDescriptor(ctx context.Context, req *monitoringpb.GetMetricDescriptorRequest) (*googlemetricpb.MetricDescriptor, error) {
return new(googlemetricpb.MetricDescriptor), nil
}

func (server *fakeMetricsServer) CreateMetricDescriptor(ctx context.Context, req *monitoringpb.CreateMetricDescriptorRequest) (*googlemetricpb.MetricDescriptor, error) {
server.mu.Lock()
server.stackdriverMetricDescriptors = append(server.stackdriverMetricDescriptors, req)
Expand All @@ -436,23 +430,3 @@ func (server *fakeMetricsServer) CreateTimeSeries(ctx context.Context, req *moni
server.mu.Unlock()
return new(empty.Empty), nil
}

func (server *fakeMetricsServer) ListTimeSeries(ctx context.Context, req *monitoringpb.ListTimeSeriesRequest) (*monitoringpb.ListTimeSeriesResponse, error) {
return new(monitoringpb.ListTimeSeriesResponse), nil
}

func (server *fakeMetricsServer) DeleteMetricDescriptor(ctx context.Context, req *monitoringpb.DeleteMetricDescriptorRequest) (*empty.Empty, error) {
return new(empty.Empty), nil
}

func (server *fakeMetricsServer) ListMetricDescriptors(ctx context.Context, req *monitoringpb.ListMetricDescriptorsRequest) (*monitoringpb.ListMetricDescriptorsResponse, error) {
return new(monitoringpb.ListMetricDescriptorsResponse), nil
}

func (server *fakeMetricsServer) GetMonitoredResourceDescriptor(ctx context.Context, req *monitoringpb.GetMonitoredResourceDescriptorRequest) (*monitoredrespb.MonitoredResourceDescriptor, error) {
return new(monitoredrespb.MonitoredResourceDescriptor), nil
}

func (server *fakeMetricsServer) ListMonitoredResourceDescriptors(ctx context.Context, req *monitoringpb.ListMonitoredResourceDescriptorsRequest) (*monitoringpb.ListMonitoredResourceDescriptorsResponse, error) {
return new(monitoringpb.ListMonitoredResourceDescriptorsResponse), nil
}

0 comments on commit 655917a

Please sign in to comment.