Skip to content

Commit

Permalink
back to no metric test - just for sanity which apparently is now sore…
Browse files Browse the repository at this point in the history
…ly lacking
  • Loading branch information
sighphyre committed Dec 8, 2023
1 parent 63993de commit a89a90f
Showing 1 changed file with 36 additions and 45 deletions.
81 changes: 36 additions & 45 deletions metrics_test.go
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit a89a90f

Please sign in to comment.