Files
aego/modules/update/browser_test.go
sanspie 962c479933
ci-platforms / darwin amd64 smoke (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
ci-platforms / windows amd64 smoke (push) Skipped
ci / checks (push) Successful in 10m24s
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 12m13s
ci / release (push) Successful in 8m57s
web: the browser build drops the self-update core (D362 amended)
modules/update links aego/update (net/http, TLS, x509, archives) only off js; the web build gets a browser backend with the same section, settings and aego/update API, where Check and Apply fail and State stays idle. A test compares both builds' registrations.
depcheck: wasm-runtime and wasm-try variants, update in wasmDenied, wasmDeniedStd (net/http, crypto/tls, crypto/x509, archive/*) with the wasm-reaches-std rule.
wasmsize -prev: playground-size and try-size print the change since their last run.
Loaders show the compressed download size: wasmGzip in an export's files.json, aego-*-gzip and data-wasm-gzip on the site; docstool writes the .wasm.gz copies.
Demo game.wasm 33.9 -> 26.0 MB, gzip 8.07 -> 6.25 MB.
2026-10-27 20:06:16 +03:00

64 lines
1.6 KiB
Go

package update
import (
"slices"
"testing"
"aego/engine/module"
"aego/scene"
"aego/schema"
"aego/script/bind"
)
func registered(t *testing.T, m *Module) (*module.Manifest, *bind.Registry) {
t.Helper()
b := bind.NewManifest()
r := module.New(scene.NewTypes(schema.NewRegistry()), b)
if err := r.Add(m); err != nil {
t.Fatal(err)
}
man, err := r.Build()
if err != nil {
t.Fatal(err)
}
if err := b.Freeze(); err != nil {
t.Fatal(err)
}
return man, b
}
// The browser build registers what the native one does: the project section, the settings and the script API.
func TestBrowserRegistersLikeNative(t *testing.T) {
nat, nb := registered(t, New())
web, wb := registered(t, &Module{b: browser{}})
ids := func(m *module.Manifest) (s []string) {
for _, sec := range m.Sections {
s = append(s, sec.ID)
}
for _, d := range m.Settings {
s = append(s, d.ID)
}
return s
}
if a, b := ids(nat), ids(web); !slices.Equal(a, b) || !slices.Contains(a, SectionID) {
t.Fatalf("sections and settings differ: native %v, browser %v", a, b)
}
if nb.ABIHash() != wb.ABIHash() {
t.Fatal("the browser build's aego/update script API differs from the native one")
}
}
func TestBrowserHasNothingToUpdate(t *testing.T) {
m := &Module{b: browser{}, sec: Section{URL: "https://example.com/updates", PublicKey: "k"}}
if err := m.Check(); err != errBrowser {
t.Fatalf("Check: %v", err)
}
m.Download()
if err := m.Apply(); err != errBrowser {
t.Fatalf("Apply: %v", err)
}
if p, v, _, msg := m.State(); p != Idle || v != "" || msg != "" {
t.Fatalf("state %v %q %q", p, v, msg)
}
}