Skip to content

Commit

Permalink
Add SendFeatureFlags test
Browse files Browse the repository at this point in the history
  • Loading branch information
zaynetro committed Feb 8, 2024
1 parent e36dc52 commit 0f75ce2
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions posthog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -929,3 +929,41 @@ func TestDisabledFlag(t *testing.T) {
t.Errorf("flag listed in /decide/ response should have value 'false'")
}
}

func TestCaptureSendFlags(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(fixture("test-api-feature-flag.json")))
}))
defer server.Close()

client, _ := NewWithConfig("Csyjlnlun3OzyNJAafdlv", Config{
Endpoint: server.URL,
Verbose: true,
Logger: t,
BatchSize: 1,
now: mockTime,
uid: mockId,

PersonalApiKey: "some very secret key",
})
defer client.Close()

// Without this call client.Close hangs forever
// Ref: https://github.com/PostHog/posthog-go/issues/28
client.IsFeatureEnabled(
FeatureFlagPayload{
Key: "simpleFlag",
DistinctId: "hey",
},
)

err := client.Enqueue(Capture{
Event: "Download",
DistinctId: "123456",
SendFeatureFlags: true,
})

if err != nil {
t.Fatal(err)
}
}

0 comments on commit 0f75ce2

Please sign in to comment.