From a89a90fb83b52d45e0e2c7bb8509435e2d584da7 Mon Sep 17 00:00:00 2001 From: sighphyre Date: Fri, 8 Dec 2023 14:52:27 +0200 Subject: [PATCH] back to no metric test - just for sanity which apparently is now sorely lacking --- metrics_test.go | 81 ++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 45 deletions(-) diff --git a/metrics_test.go b/metrics_test.go index 9701549..25ff863 100644 --- a/metrics_test.go +++ b/metrics_test.go @@ -1,14 +1,5 @@ package unleash -import ( - "testing" - "time" - - "github.com/Unleash/unleash-client-go/v4/api" - "github.com/stretchr/testify/assert" - "gopkg.in/h2non/gock.v1" -) - // func TestMetrics_RegisterInstance(t *testing.T) { // assert := assert.New(t) // defer gock.OffAll() @@ -123,42 +114,42 @@ import ( // assert.True(gock.IsDone(), "there should be no more mocks") // } -func TestMetrics_DisabledMetrics(t *testing.T) { - assert := assert.New(t) - defer gock.OffAll() - - gock.New(mockerServer). - Get("/client/features"). - Reply(200). - JSON(api.FeatureResponse{}) - - mockListener := &DebugListener{} - // mockListener.On("OnReady").Return() - - client, err := NewClient( - WithUrl(mockerServer), - WithDisableMetrics(false), - WithMetricsInterval(100*time.Millisecond), - WithAppName(mockAppName), - WithInstanceId(mockInstanceId), - WithListener(mockListener), - ) - assert.Nil(err, "client should not return an error") - - client.IsEnabled("bar") - - assert.True(true) - - client.Close() - // client.WaitForReady() - // client.IsEnabled("foo") - // client.IsEnabled("bar") - // client.IsEnabled("baz") - - // time.Sleep(300 * time.Millisecond) - // client.Close() - // assert.True(gock.IsDone(), "there should be no more mocks") -} +// func TestMetrics_DisabledMetrics(t *testing.T) { +// assert := assert.New(t) +// defer gock.OffAll() + +// gock.New(mockerServer). +// Get("/client/features"). +// Reply(200). +// JSON(api.FeatureResponse{}) + +// mockListener := &DebugListener{} +// // mockListener.On("OnReady").Return() + +// client, err := NewClient( +// WithUrl(mockerServer), +// WithDisableMetrics(false), +// WithMetricsInterval(100*time.Millisecond), +// WithAppName(mockAppName), +// WithInstanceId(mockInstanceId), +// WithListener(mockListener), +// ) +// assert.Nil(err, "client should not return an error") + +// client.IsEnabled("bar") + +// assert.True(true) + +// client.Close() +// client.WaitForReady() +// client.IsEnabled("foo") +// client.IsEnabled("bar") +// client.IsEnabled("baz") + +// time.Sleep(300 * time.Millisecond) +// client.Close() +// assert.True(gock.IsDone(), "there should be no more mocks") +// } // // TestMetrics_SendMetricsFail tests that no metrics are lost if /client/metrics // // fails temporarily.