CI / test (push) Failing after 42s
People sign up on the website and link IMVU accounts by putting a code in the account's tagline, which the hub reads from IMVU's public API (the most recent proof wins; link caps per person). IMVU's age verification or Access Pass make an account adult. T5DE's proxy signs in with a device code and keeps a WebSocket open, reporting the IMVU account in use and the community products it wears; /online shows those who opted in. Moderators get a console: who's online, people, link caps, bans, roles, and the audit log. Tests run the website and API against an embedded Postgres and a fake IMVU API. Co-Authored-By: Claude Opus 5.5 <[email protected]>
31 lines
1022 B
Go
31 lines
1022 B
Go
package imvu
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestByUsername(t *testing.T) {
|
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
if r.URL.Query().Get("username") == "Nobody" {
|
|
w.Write([]byte(`{"status":"success","id":"x","denormalized":{}}`))
|
|
return
|
|
}
|
|
w.Write([]byte(`{"status":"success","id":"https://api.imvu.com/user?username=Someone","denormalized":{
|
|
"https://api.imvu.com/user/user-42":{"data":{"legacy_cid":42,"username":"Someone","tagline":"hi t5de-ABCD",
|
|
"is_ageverified":true,"is_ap":false}}}}`))
|
|
}))
|
|
defer srv.Close()
|
|
c := &Client{Base: srv.URL, HTTP: srv.Client()}
|
|
u, err := c.ByUsername(context.Background(), "Someone")
|
|
if err != nil || u.ID != 42 || u.Username != "Someone" || u.Tagline != "hi t5de-ABCD" || !u.AgeVerified || u.AccessPass {
|
|
t.Fatalf("%+v %v", u, err)
|
|
}
|
|
if _, err := c.ByUsername(context.Background(), "Nobody"); !errors.Is(err, ErrNoSuchUser) {
|
|
t.Fatalf("got %v", err)
|
|
}
|
|
}
|