mirror of
https://github.com/hanzoai/insights-go.git
synced 2026-09-30 22:46:12 +00:00
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)
55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
package insights
|
|
|
|
import "testing"
|
|
|
|
func TestCaptureMissingEvent(t *testing.T) {
|
|
capture := Capture{
|
|
DistinctId: "1",
|
|
}
|
|
|
|
if err := capture.Validate(); err == nil {
|
|
t.Error("validating an invalid capture object succeeded:", capture)
|
|
|
|
} else if e, ok := err.(FieldError); !ok {
|
|
t.Error("invalid error type returned when validating capture:", err)
|
|
|
|
} else if e != (FieldError{
|
|
Type: "insights.Capture",
|
|
Name: "Event",
|
|
Value: "",
|
|
}) {
|
|
t.Error("invalid error value returned when validating capture:", err)
|
|
}
|
|
}
|
|
|
|
func TestCaptureMissingDistinctId(t *testing.T) {
|
|
capture := Capture{
|
|
Event: "1",
|
|
}
|
|
|
|
if err := capture.Validate(); err == nil {
|
|
t.Error("validating an invalid capture object succeeded:", capture)
|
|
|
|
} else if e, ok := err.(FieldError); !ok {
|
|
t.Error("invalid error type returned when validating capture:", err)
|
|
|
|
} else if e != (FieldError{
|
|
Type: "insights.Capture",
|
|
Name: "DistinctId",
|
|
Value: "",
|
|
}) {
|
|
t.Error("invalid error value returned when validating capture:", err)
|
|
}
|
|
}
|
|
|
|
func TestCaptureValidWithDistinctId(t *testing.T) {
|
|
capture := Capture{
|
|
Event: "1",
|
|
DistinctId: "2",
|
|
}
|
|
|
|
if err := capture.Validate(); err != nil {
|
|
t.Error("validating a valid capture object failed:", capture, err)
|
|
}
|
|
}
|