Files
zeekay 1b367e2b62 chore: rebase the tree onto upstream master
The tree was a debranded snapshot of upstream taken around 2026-02-20, and
upstream has moved about five months since. This replaces it with upstream
master, mechanically re-derived: bin/debrand does the rename, and the
pipeline and squashed migrations are restored from the shipped tree.

Not a merge. The previous import replaced the tree wholesale in a single
commit, so there is no shared content history to merge against. Reproducing
the rename on the new tree is what actually converges.

What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints,
compose files, LLM.md, and insights/migrations. The squashed initial
migration is load-bearing — the live database records it by name, so
upstream's ~918 individual migrations cannot come back.

Nine products are dropped as unreferenced. Twenty-one more that we do not run
are kept anyway because the core app still imports them; unpicking those is a
refactor and does not belong in a rebase.

This base does not build yet, and the reasons are not in the rename:
upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against
our 4.2, and the dependency manifests still name upstream packages that we
republish under our own names. Those are decisions, not renames.
2026-08-01 15:44:40 -07:00

164 lines
4.1 KiB
Go

package configs
import (
"github.com/spf13/viper"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestLoadConfig(t *testing.T) {
tests := []struct {
name string
setup func()
want *Config
wantErr bool
}{
{
name: "load all config values",
setup: func() {
// Values already set in setupTestConfig
_ = os.Setenv("LIVESTREAM_JWT_SECRET", "token")
},
want: &Config{
Debug: true,
MMDB: MMDBConfig{Path: "mmdb.db"},
Parallelism: 7,
CORSAllowOrigins: []string{"https://example.com", "https://sub.example.com"},
Consumers: ConsumersConfig{
Event: ConsumerConfig{
Enabled: true,
Brokers: "localhost:9092,localhost:9093",
Topic: "events_topic",
SecurityProtocol: "PLAINTEXT",
GroupID: "livestream-dev",
},
SessionRecording: ConsumerConfig{
Enabled: true,
Brokers: "localhost:9092,localhost:9093",
Topic: "session_recording_snapshot_item_events",
SecurityProtocol: "SSL",
GroupID: "livestream-dev-session-recordings",
},
Notification: ConsumerConfig{
Brokers: "localhost:9092,localhost:9093",
Topic: "notification_events",
SecurityProtocol: "PLAINTEXT",
GroupID: "livestream-dev-notifications",
},
},
JWT: JWTConfig{
Secret: "token",
SecretFallbacks: []string{"<previous secret key>"},
},
SessionRecording: SessionRecordingConfig{
MaxLRUEntries: 2_000_000_000,
},
Redis: RedisConfig{
FlushIntervalMs: 500,
PublishBufferSize: 10000,
PublishWorkers: 256,
},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tt.setup()
InitConfigs("configs.example", ".")
got, err := LoadConfig()
if tt.wantErr {
assert.Error(t, err)
return
}
assert.NoError(t, err)
assert.Equal(t, tt.want, got)
assert.Equal(t, tt.want.JWT.Secret, viper.GetString("jwt.secret"))
})
}
}
func TestValidateConsumerConfig(t *testing.T) {
tests := []struct {
name string
consumerName string
config ConsumerConfig
wantErr string
}{
{
name: "disabled consumer skips validation",
consumerName: "event",
config: ConsumerConfig{Enabled: false},
},
{
name: "valid config passes",
consumerName: "event",
config: ConsumerConfig{
Enabled: true,
Brokers: "localhost:9092",
Topic: "events_topic",
SecurityProtocol: "PLAINTEXT",
GroupID: "livestream-dev",
},
},
{
name: "missing brokers",
consumerName: "event",
config: ConsumerConfig{
Enabled: true,
Topic: "events_topic",
SecurityProtocol: "PLAINTEXT",
GroupID: "livestream-dev",
},
wantErr: "consumers.event.brokers must be set",
},
{
name: "missing topic",
consumerName: "session_recording",
config: ConsumerConfig{
Enabled: true,
Brokers: "localhost:9092",
SecurityProtocol: "SSL",
GroupID: "livestream-dev",
},
wantErr: "consumers.session_recording.topic must be set",
},
{
name: "missing security_protocol",
consumerName: "notification",
config: ConsumerConfig{
Enabled: true,
Brokers: "localhost:9092",
Topic: "notification_events",
GroupID: "livestream-dev",
},
wantErr: "consumers.notification.security_protocol must be set",
},
{
name: "missing group_id",
consumerName: "event",
config: ConsumerConfig{
Enabled: true,
Brokers: "localhost:9092",
Topic: "events_topic",
SecurityProtocol: "PLAINTEXT",
},
wantErr: "consumers.event.group_id must be set",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := validateConsumerConfig(tt.consumerName, tt.config)
if tt.wantErr != "" {
assert.EqualError(t, err, tt.wantErr)
} else {
assert.NoError(t, err)
}
})
}
}