diff --git a/client_test.go b/client_test.go index f80abdc..adb6c19 100644 --- a/client_test.go +++ b/client_test.go @@ -55,49 +55,49 @@ import ( // assert.True(gock.IsDone(), "there should be no more mocks") // } -// func TestClient_WithFallbackFunc(t *testing.T) { -// assert := assert.New(t) -// defer gock.OffAll() +func TestClient_WithFallbackFunc(t *testing.T) { + assert := assert.New(t) + defer gock.OffAll() -// gock.New(mockerServer). -// Post("/client/register"). -// MatchHeader("UNLEASH-APPNAME", mockAppName). -// MatchHeader("UNLEASH-INSTANCEID", mockInstanceId). -// Reply(200) + gock.New(mockerServer). + Post("/client/register"). + MatchHeader("UNLEASH-APPNAME", mockAppName). + MatchHeader("UNLEASH-INSTANCEID", mockInstanceId). + Reply(200) -// gock.New(mockerServer). -// Get("/client/features"). -// Reply(200). -// JSON(api.FeatureResponse{}) + gock.New(mockerServer). + Get("/client/features"). + Reply(200). + JSON(api.FeatureResponse{}) -// feature := "does_not_exist" + feature := "does_not_exist" -// mockListener := &MockedListener{} -// mockListener.On("OnReady").Return() -// mockListener.On("OnRegistered", mock.AnythingOfType("ClientData")) -// mockListener.On("OnCount", feature, true).Return() -// mockListener.On("OnError").Return() + mockListener := &MockedListener{} + mockListener.On("OnReady").Return() + mockListener.On("OnRegistered", mock.AnythingOfType("ClientData")) + mockListener.On("OnCount", feature, true).Return() + mockListener.On("OnError").Return() -// client, err := NewClient( -// WithUrl(mockerServer), -// WithAppName(mockAppName), -// WithInstanceId(mockInstanceId), -// WithListener(mockListener), -// ) + client, err := NewClient( + WithUrl(mockerServer), + WithAppName(mockAppName), + WithInstanceId(mockInstanceId), + WithListener(mockListener), + ) -// assert.NoError(err) + assert.NoError(err) -// client.WaitForReady() + client.WaitForReady() -// fallback := func(f string, ctx *context.Context) bool { -// return f == feature -// } + fallback := func(f string, ctx *context.Context) bool { + return f == feature + } -// isEnabled := client.IsEnabled("does_not_exist", WithFallbackFunc(fallback)) -// assert.True(isEnabled) + isEnabled := client.IsEnabled("does_not_exist", WithFallbackFunc(fallback)) + assert.True(isEnabled) -// assert.True(gock.IsDone(), "there should be no more mocks") -// } + assert.True(gock.IsDone(), "there should be no more mocks") +} func TestClient_WithResolver(t *testing.T) { assert := assert.New(t)