From 8e70ee0bcfd8c0fc25641b1bd540a662537752c2 Mon Sep 17 00:00:00 2001 From: S-H1129 Date: Thu, 22 Apr 2021 11:48:04 +0900 Subject: [PATCH] fix: fix test --- pkg/bucketeer/metrics_test.go | 5 +++-- pkg/bucketeer/sdk.go | 3 ++- pkg/bucketeer/sdk_test.go | 34 +++++++++++++++++----------------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/pkg/bucketeer/metrics_test.go b/pkg/bucketeer/metrics_test.go index 3dd5376..d1b4bc6 100644 --- a/pkg/bucketeer/metrics_test.go +++ b/pkg/bucketeer/metrics_test.go @@ -2,10 +2,11 @@ package bucketeer import ( "context" + "testing" + "github.com/stretchr/testify/assert" "go.opencensus.io/stats/view" "go.opencensus.io/tag" - "testing" ) func TestRegisterMetrics(t *testing.T) { @@ -26,7 +27,7 @@ func TestNewMetricsContext(t *testing.T) { assert.Equal(t, expectedCtx, ctx) } -func TestNewLatencyDistribution(t *testing.T){ +func TestNewLatencyDistribution(t *testing.T) { expected := view.Distribution(25, 50, 100, 200, 400, 800, 1600, 3200, 6400).Buckets assert.Equal(t, expected, newLatencyDistribution().Buckets) } diff --git a/pkg/bucketeer/sdk.go b/pkg/bucketeer/sdk.go index 1d2f9b8..68a8a43 100644 --- a/pkg/bucketeer/sdk.go +++ b/pkg/bucketeer/sdk.go @@ -5,10 +5,11 @@ import ( "encoding/json" "errors" "fmt" - "go.opencensus.io/tag" "strconv" "time" + "go.opencensus.io/tag" + "github.com/golang/protobuf/proto" // nolint:staticcheck "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/pkg/bucketeer/sdk_test.go b/pkg/bucketeer/sdk_test.go index a1a6408..6877a44 100644 --- a/pkg/bucketeer/sdk_test.go +++ b/pkg/bucketeer/sdk_test.go @@ -47,7 +47,7 @@ func TestBoolVariation(t *testing.T) { ) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushInternalErrorCountMetricsEvent(ctx, sdkTag) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushDefaultEvaluationEvent( - context.Background(), + ctx, user.User, featureID, ) @@ -74,7 +74,7 @@ func TestBoolVariation(t *testing.T) { sdkTag, ) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushDefaultEvaluationEvent( - context.Background(), + ctx, user.User, featureID, ) @@ -101,7 +101,7 @@ func TestBoolVariation(t *testing.T) { sdkTag, ) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushEvaluationEvent( - context.Background(), + ctx, user.User, res.Evaluation, ) @@ -147,7 +147,7 @@ func TestIntVariation(t *testing.T) { ) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushInternalErrorCountMetricsEvent(ctx, sdkTag) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushDefaultEvaluationEvent( - context.Background(), + ctx, user.User, featureID, ) @@ -174,7 +174,7 @@ func TestIntVariation(t *testing.T) { sdkTag, ) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushDefaultEvaluationEvent( - context.Background(), + ctx, user.User, featureID, ) @@ -201,7 +201,7 @@ func TestIntVariation(t *testing.T) { sdkTag, ) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushEvaluationEvent( - context.Background(), + ctx, user.User, res.Evaluation, ) @@ -247,7 +247,7 @@ func TestInt64Variation(t *testing.T) { ) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushInternalErrorCountMetricsEvent(ctx, sdkTag) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushDefaultEvaluationEvent( - context.Background(), + ctx, user.User, featureID, ) @@ -274,7 +274,7 @@ func TestInt64Variation(t *testing.T) { sdkTag, ) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushDefaultEvaluationEvent( - context.Background(), + ctx, user.User, featureID, ) @@ -301,7 +301,7 @@ func TestInt64Variation(t *testing.T) { sdkTag, ) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushEvaluationEvent( - context.Background(), + ctx, user.User, res.Evaluation, ) @@ -347,7 +347,7 @@ func TestFloat64Variation(t *testing.T) { ) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushInternalErrorCountMetricsEvent(ctx, sdkTag) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushDefaultEvaluationEvent( - context.Background(), + ctx, user.User, featureID, ) @@ -374,7 +374,7 @@ func TestFloat64Variation(t *testing.T) { sdkTag, ) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushDefaultEvaluationEvent( - context.Background(), + ctx, user.User, featureID, ) @@ -401,7 +401,7 @@ func TestFloat64Variation(t *testing.T) { sdkTag, ) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushEvaluationEvent( - context.Background(), + ctx, user.User, res.Evaluation, ) @@ -447,7 +447,7 @@ func TestStringVariation(t *testing.T) { ) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushInternalErrorCountMetricsEvent(ctx, sdkTag) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushDefaultEvaluationEvent( - context.Background(), + ctx, user.User, featureID, ) @@ -474,7 +474,7 @@ func TestStringVariation(t *testing.T) { sdkTag, ) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushEvaluationEvent( - context.Background(), + ctx, user.User, res.Evaluation, ) @@ -524,7 +524,7 @@ func TestJSONVariation(t *testing.T) { ) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushInternalErrorCountMetricsEvent(ctx, sdkTag) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushDefaultEvaluationEvent( - context.Background(), + ctx, user.User, featureID, ) @@ -551,7 +551,7 @@ func TestJSONVariation(t *testing.T) { sdkTag, ) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushDefaultEvaluationEvent( - context.Background(), + ctx, user.User, featureID, ) @@ -578,7 +578,7 @@ func TestJSONVariation(t *testing.T) { sdkTag, ) s.eventProcessor.(*mockevent.MockProcessor).EXPECT().PushEvaluationEvent( - context.Background(), + ctx, user.User, res.Evaluation, )