Skip to content

Commit

Permalink
test: add test for #800
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Aug 6, 2023
1 parent 701a276 commit 02bc827
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions subscribe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,26 @@ func TestSubscribeLogLevelInfo(t *testing.T) {
assert.Equal(t, 0, logs.FilterMessage("New subscriber").FilterFieldKey("payload").Len())
}

func TestSubscribeLogAnonymousSubscriber(t *testing.T) {
core, logs := observer.New(zapcore.DebugLevel)

h := createAnonymousDummy(WithLogger(zap.New(core)))

ctx, cancel := context.WithCancel(context.Background())
req := httptest.NewRequest(http.MethodGet, defaultHubURL+"?topic=http://example.com/", nil).WithContext(ctx)

w := &responseTester{
expectedStatusCode: http.StatusOK,
expectedBody: ":\n",
t: t,
cancel: cancel,
}

h.SubscribeHandler(w, req)

assert.Equal(t, 0, logs.FilterMessage("New subscriber").FilterFieldKey("payload").Len())
}

func TestUnsubscribe(t *testing.T) {
hub := createAnonymousDummy()

Expand Down

0 comments on commit 02bc827

Please sign in to comment.