@@ -4,7 +4,10 @@ package event
4// scenarios. These tests will not log anything.
4// scenarios. These tests will not log anything.
10+ "github.com/posthog/posthog-go"
10func TestError(t *testing.T) {
13func TestError(t *testing.T) {
@@ -59,6 +62,33 @@ func TestError(t *testing.T) {
65+func TestPairsToProps(t *testing.T) {
66+ t.Run("sets valid key value pairs", func(t *testing.T) {
67+ got := pairsToProps("foo", "bar", "count", 3)
68+ want := posthog.NewProperties().
71+ if !reflect.DeepEqual(got, want) {
72+ t.Fatalf("pairsToProps() = %#v, want %#v", got, want)
76+ t.Run("returns empty properties for odd pairs", func(t *testing.T) {
77+ got := pairsToProps("foo", "bar", "count")
79+ t.Fatalf("pairsToProps() should return empty properties, got %#v", got)
83+ t.Run("ignores non-string key and continues", func(t *testing.T) {
84+ got := pairsToProps(123, "bad", "ok", true)
85+ want := posthog.NewProperties().Set("ok", true)
86+ if !reflect.DeepEqual(got, want) {
87+ t.Fatalf("pairsToProps() = %#v, want %#v", got, want)
62// newDefaultTestError creates a test error that mimics runtime panic
92// newDefaultTestError creates a test error that mimics runtime panic
63// errors. This helps us testing that the Error function can handle various
93// errors. This helps us testing that the Error function can handle various
64// error types, including those that might be passed from a panic recovery
94// error types, including those that might be passed from a panic recovery