Files
aego/project/remoteexample/package_test.go
sanspie 50be5c04bc
ci-platforms / darwin amd64 smoke (push) Skipped
GitHub / linux amd64 native GitHub-hosted native CI: success
ci-platforms / windows amd64 smoke (push) Skipped
GitHub / windows amd64 native GitHub-hosted native CI: success
GitHub / darwin arm64 native GitHub-hosted native CI: success
GitHub / darwin amd64 native GitHub-hosted native CI: success
ci / checks (push) Failing after 1h21m34s
ci / native-authoring (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
github-native / gitea-pending (push) Skipped
github-native / darwin amd64 native (push) Skipped
github-native / linux amd64 native (push) Skipped
github-native / windows amd64 native (push) Skipped
github-native / darwin arm64 native (push) Skipped
github-native / gitea-result (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 12m4s
ci / release (push) Skipped
Stage 12.5: Art Workspace and asset authoring
Add dockable Art tools, animation and previews, guarded asset workflows,
and the Web Asset Studio built on the shared Art Core. Expand English and
Russian documentation, interactive Try scenes, examples and editor icons.

Add audio waveform navigation, source analysis, guarded previews and a
browser Worker mixer. Preserve source changes and recovery with bounded
checks, and strengthen native, browser and interoperability CI.

Prepare version 0.12.5 and manually built native artifact candidates.
Fix the production site image demo build dependency.
Reuse immutable scene indices when capturing keyframes.
Wait for real Persist save/load completion in component tests.
Stabilize browser Game View captures outside pointer hover.
Aseprite interchange and persistent Audio EDL recovery remain limited;
the artifact workflow does not publish releases or change stable.
2026-11-15 10:37:50 +03:00

116 lines
4.1 KiB
Go

package remoteexample
import (
"archive/zip"
"bytes"
"context"
"io"
"os"
"path/filepath"
"testing"
)
func TestBuildPackageUsesExistingHTTPSCloneAndOfflineStore(t *testing.T) {
f := newFixture(t)
files := map[string][]byte{
"project.aego": []byte("project version=1 { name=\"Complete\" module=\"game\" native=false }\n"),
"scenes/main.aescene": []byte("scene version=1 {}\n"),
"scripts/demo.aes": []byte("package demo\n"),
"assets/sprite.png": {137, 80, 78, 71},
"assets/sprite.png.meta": []byte("meta version=1 { id=\"10000000000000000000000000000001\" importer=\"texture\" }\n"),
}
m := f.m
m.AssetRefs = []string{"10000000000000000000000000000001"}
m, manifest, archive, err := BuildPackage(m, files, f.url(), Limits{})
if err != nil {
t.Fatal(err)
}
_, manifest2, archive2, err := BuildPackage(m, files, f.url(), Limits{})
if err != nil || !bytes.Equal(manifest, manifest2) || !bytes.Equal(archive, archive2) {
t.Fatal("identical sources did not produce identical package bytes", err)
}
parsed, err := ParseManifest(manifest, f.url(), Limits{})
if err != nil || parsed.Archive.SHA256 != hashBytes(archive) || len(parsed.AssetRefs) != 1 {
t.Fatal("distribution manifest does not describe archive/ref bytes", err)
}
z, err := zip.NewReader(bytes.NewReader(archive), int64(len(archive)))
if err != nil || len(z.File) != len(files) {
t.Fatal("bad source ZIP", err)
}
for _, file := range z.File {
r, err := file.Open()
if err != nil {
t.Fatal(err)
}
b, err := io.ReadAll(r)
r.Close()
if err != nil || !bytes.Equal(b, files[file.Name]) {
t.Fatalf("source bytes changed: %s, %v", file.Name, err)
}
}
f.mu.Lock()
f.m, f.packed = m, archive
f.mu.Unlock()
copy := f.clone(t)
for name, want := range files {
b, err := os.ReadFile(filepath.Join(copy.Directory, name))
if err != nil || !bytes.Equal(b, want) {
t.Fatalf("complete source was lost in HTTPS install: %s: %v", name, err)
}
}
user := []byte("scene version=1 { node \"123\" name=\"My edit\" {} }\n")
if err := os.WriteFile(copy.Entry, user, 0600); err != nil {
t.Fatal(err)
}
f.server.Close()
local, err := f.store.OpenRecent(f.url())
if err != nil {
t.Fatal(err)
}
got, err := os.ReadFile(local.Entry)
if err != nil || !bytes.Equal(got, user) {
t.Fatal("offline open lost edited source", err)
}
if _, err := f.client.CheckUpdate(context.Background(), local, f.server.URL); err == nil {
t.Fatal("offline update check unexpectedly succeeded")
}
got, _ = os.ReadFile(local.Entry)
if !bytes.Equal(got, user) {
t.Fatal("failed update changed local work")
}
}
func TestBuildPackageRejectsIncompleteOrUnsafeSources(t *testing.T) {
base := map[string][]byte{"project.aego": []byte("project {}"), "scenes/main.aescene": []byte("scene {}")}
m := exampleManifest("https://examples.test", []byte("placeholder"), base)
for _, name := range []string{"../outside.txt", "/absolute.txt", "assets/CLOCK$.txt", "assets/secret.env", ".git/config", "engine/main.go", "native/addon.dll", "assets/scene.aescene:ads", "remote-example.receipt.json"} {
t.Run(name, func(t *testing.T) {
files := map[string][]byte{}
for p, data := range base {
files[p] = data
}
files[name] = []byte("bad")
if _, _, _, err := BuildPackage(m, files, "https://examples.test/manifest.json", Limits{}); err == nil {
t.Fatal("unsafe package accepted")
}
})
}
for _, change := range []func(*Manifest){
func(m *Manifest) { m.EntryScene = "scenes/missing.aescene" },
func(m *Manifest) { m.Archive.URL = "https://elsewhere.test/project.zip" },
func(m *Manifest) { m.AssetRefs = []string{"bad"} },
func(m *Manifest) {
m.AssetRefs = []string{"10000000000000000000000000000001", "10000000000000000000000000000001"}
},
} {
copy := m
change(&copy)
if _, _, _, err := BuildPackage(copy, base, "https://examples.test/manifest.json", Limits{}); err == nil {
t.Fatal("invalid package metadata accepted")
}
}
if _, _, _, err := BuildPackage(m, base, "https://examples.test/manifest.json", Limits{ArchiveBytes: 16}); err == nil {
t.Fatal("archive byte budget ignored")
}
}