Add HTTP /v1 MVC, TCP send path, groups with server-side member-avatar collage, object-storage upload, and friends/favorites around the architecture-v3 layout. Co-authored-by: Cursor <cursoragent@cursor.com>
21 lines
553 B
Go
21 lines
553 B
Go
package protocol
|
|
|
|
import "testing"
|
|
|
|
func TestAuthRequestJSONRoundTrip(t *testing.T) {
|
|
raw := EncodeAuthRequest(AuthRequest{Token: "abc", DeviceID: 7, AppVersion: "1.0", Language: "zh-CN"})
|
|
got, err := DecodeAuthRequest(raw)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got.Token != "abc" || got.DeviceID != 7 || got.Language != "zh-CN" {
|
|
t.Fatalf("%+v", got)
|
|
}
|
|
if _, err := DecodeAuthRequest([]byte(`{"device_id":1}`)); err == nil {
|
|
t.Fatal("empty token")
|
|
}
|
|
if _, err := DecodeAuthRequest([]byte("not-json")); err == nil {
|
|
t.Fatal("garbage")
|
|
}
|
|
}
|