package codex import "testing" func TestCodexRateLimitNotice(t *testing.T) { raw := []byte(`{"method":"account/rateLimits/updated","params":{"rateLimits":{"limitId":"codex","planType":"promax","primary":{"usedPercent":100,"windowDurationMins":10080,"resetsAt":1794297404},"secondary":null,"credits":{"hasCredits":true,"unlimited":false,"balance":"1"}}}}`) events, err := Decode(raw) if err != nil || len(events) != 0 { t.Fatalf("global rate notice became a session event: %+v %v", events, err) } for _, raw := range []string{ `{"id":1,"method":"account/rateLimits/updated","params":{"rateLimits":{}}}`, `{"method":"account/rateLimits/updated","params":{"rateLimits":null}}`, `{"method":"account/rateLimits/updated","params":{"rateLimits":{},"threadId":"other"}}`, `{"method":"account/rateLimits/updated","params":{}}`, } { if _, err := Decode([]byte(raw)); err == nil { t.Fatal("unexpected rate notice accepted", raw) } } }