Files
insights-go/properties_test.go
zeekay b4e1366340 rebrand: export Insights types instead of PostHog
Rename Go package from posthog to insights across all 80+ files.
Consumers now import as `insights "github.com/hanzoai/insights-go"`
and use insights.Client, insights.Config, insights.Capture, etc.

- Rename posthog.go -> insights.go, posthog_test.go -> insights_test.go
- Update package declaration from posthog to insights in all .go files
- Update SDKName from posthog-go to insights-go
- Update DefaultEndpoint from app.posthog.com to insights.hanzo.ai
- Update all FieldError/ConfigError type strings
- Update User-Agent headers, log prefixes, comments, and docs
- Update JSON test fixtures to match new SDK name
- Update CLI, examples, extras, and sdk_compliance_adapter
- Fix pre-existing go vet warnings (non-constant format strings)
2026-03-13 19:54:58 -07:00

62 lines
1.6 KiB
Go

package insights
import (
"reflect"
"testing"
)
func TestPropertiesSimple(t *testing.T) {
text := "ABC"
number := 0.5
tests := map[string]struct {
ref Properties
run func(Properties)
}{
"revenue": {Properties{"revenue": number}, func(p Properties) { p.Set("revenue", number) }},
"currency": {Properties{"currency": text}, func(p Properties) { p.Set("currency", text) }},
}
for name, test := range tests {
prop := NewProperties()
test.run(prop)
if !reflect.DeepEqual(prop, test.ref) {
t.Errorf("%s: invalid properties produced: %#v\n", name, prop)
}
}
}
func TestPropertiesMulti(t *testing.T) {
p0 := Properties{"title": "A", "value": 0.5}
p1 := NewProperties().Set("title", "A").Set("value", 0.5)
if !reflect.DeepEqual(p0, p1) {
t.Errorf("invalid properties produced by chained setters:\n- expected %#v\n- found: %#v", p0, p1)
}
}
func TestPropertiesMerge(t *testing.T) {
defaultProps := Properties{"currency": "USD", "service": "api"}
props := NewProperties().Set("title", "A").Set("value", 0.5).Set("currency", "BRL")
props.Merge(defaultProps)
expected := Properties{"title": "A", "value": 0.5, "currency": "USD", "service": "api"}
if !reflect.DeepEqual(props, expected) {
t.Errorf("invalid properties produced by merge:\n- expected %#v\n- found: %#v", expected, props)
}
}
func TestPropertiesMergeNil(t *testing.T) {
props := NewProperties().Set("title", "A")
props.Merge(nil)
expected := Properties{"title": "A"}
if !reflect.DeepEqual(props, expected) {
t.Errorf("invalid properties produced by merge:\n- expected %#v\n- found: %#v", expected, props)
}
}