Switch from Asuka to MyGo, keeping the API client and the feature set: - servers: saved servers, passwordless and password login, proxy, self-signed certificates, per-server device tokens (Keystore), connect form, instance list sheet with switch/disconnect - sessions: virtualized list, search, new session, rename/archive/delete, running indicator, event stream keeps it live - chat: pushed window with system back bar, streaming Markdown via ui/markdown, reasoning and tool rows with image previews, footer menu (read aloud via a Kotlin TTS plugin, copy, fork), user message menu (copy, revert, fork), context usage ring and detail sheet, attachments (photos/files via the document picker), permissions - release builds allow plain http:// LAN servers (Go's net/http dials directly, no cleartext manifest needed) - a local fork of MyGo (third_party/mygo) lowers the Android host's minSdk to 24 (Android 7.0); Go 1.27.4 via mise Version 0.3.0.
52 lines
1.5 KiB
Go
52 lines
1.5 KiB
Go
package tsgen
|
|
|
|
import (
|
|
"encoding/json/v2"
|
|
"reflect"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
type quotedNumber int64
|
|
|
|
type customNumber int64
|
|
|
|
func (customNumber) MarshalJSON() ([]byte, error) { return []byte(`{"value":1}`), nil }
|
|
|
|
func TestQuotedNumberPointers(t *testing.T) {
|
|
type payload struct {
|
|
Count *int64 `json:"count,string"`
|
|
Nested **int64 `json:"nested,string"`
|
|
Optional *int64 `json:"optional,string,omitempty"`
|
|
Named *quotedNumber `json:"named,string"`
|
|
Custom *customNumber `json:"custom,string"`
|
|
}
|
|
n := int64(9007199254740993)
|
|
p := &n
|
|
named, custom := quotedNumber(n), customNumber(1)
|
|
value := payload{Count: p, Nested: &p, Named: &named, Custom: &custom}
|
|
wire, err := json.Marshal(value)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if want := `{"count":"9007199254740993","nested":"9007199254740993","named":"9007199254740993","custom":{"value":1}}`; string(wire) != want {
|
|
t.Fatalf("wire = %s", wire)
|
|
}
|
|
wire, err = json.Marshal(payload{})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if want := `{"count":null,"nested":null,"named":null,"custom":null}`; string(wire) != want {
|
|
t.Fatalf("nil wire = %s", wire)
|
|
}
|
|
out, err := Generate(Model{Events: []Event{{Name: "payload", Type: reflect.TypeFor[payload]()}}})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, want := range []string{"count: string | null;", "nested: string | null;", "optional?: string;", "named: string | null;", "custom: unknown | null;"} {
|
|
if !strings.Contains(string(out), want) {
|
|
t.Errorf("client lacks %s:\n%s", want, out)
|
|
}
|
|
}
|
|
}
|