Skip to content

Commit

Permalink
test: client sends identification headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Tymek committed Jan 28, 2025
1 parent 558cd96 commit 0b051cc
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1417,3 +1417,36 @@ func TestGetVariant_FallbackVariantFeatureEnabledSettingIsLeftUnchanged(t *testi

assert.True(gock.IsDone(), "there should be no more mocks")
}

func TestSendIdentificationHeaders(t *testing.T) {
assert := assert.New(t)
defer gock.OffAll()

gock.New(mockerServer).
Post("/client/register").
MatchHeader("X-UNLEASH-APPNAME", mockAppName).
MatchHeader("X-UNLEASH-SDK", `unleash-client-go:\d+\.\d+\.\d+`).
MatchHeader("X-UNLEASH-CONNECTION-ID", `[0-9a-f\-]{36}`).
Reply(200)

gock.New(mockerServer).
Get("/client/features").
MatchHeader("X-UNLEASH-APPNAME", mockAppName).
MatchHeader("X-UNLEASH-SDK", `unleash-client-go:\d+\.\d+\.\d+`).
MatchHeader("X-UNLEASH-CONNECTION-ID", `[0-9a-f\-]{36}`).
Reply(200).
JSON(api.FeatureResponse{})

client, err := NewClient(
WithUrl(mockerServer),
WithAppName(mockAppName),
WithInstanceId(mockInstanceId),
WithListener(&NoopListener{}),
)

assert.NoError(err)

client.WaitForReady()

assert.True(gock.IsDone(), "there should be no more mocks")
}

0 comments on commit 0b051cc

Please sign in to comment.