Files
AetherForge/server/internal/builder/fusion_zip_test.go
AetherForge ea6f54ad03 Expand test coverage across server, agent, and web; fix bugs found during audit.
Adds hundreds of unit/integration/e2e tests, fixes WS bcrypt auth, config merge, fleet analytics, agent schedule/log tail, and documents stale PROBLEMS items. Updates PROBLEMS.md, README, and test scripts; ignores local spread-kits and coverage dirs.
2026-05-31 01:13:58 -07:00

44 lines
958 B
Go

package builder
import (
"archive/zip"
"os"
"path/filepath"
"testing"
)
func TestZipDirectory(t *testing.T) {
dir := t.TempDir()
if err := os.WriteFile(filepath.Join(dir, "README.txt"), []byte("hi"), 0644); err != nil {
t.Fatal(err)
}
zipPath := filepath.Join(t.TempDir(), "pkg.zip")
if err := zipDirectory(dir, zipPath); err != nil {
t.Fatal(err)
}
r, err := zip.OpenReader(zipPath)
if err != nil {
t.Fatal(err)
}
defer r.Close()
if len(r.File) != 1 || r.File[0].Name != "README.txt" {
t.Fatalf("unexpected zip contents: %+v", r.File)
}
}
func TestFusionBundleZipName(t *testing.T) {
got := fusionBundleZipName("My Title")
if got != "My-Title-package.zip" {
t.Fatalf("got %q", got)
}
}
func TestZipDirectoryRejectsInsideSource(t *testing.T) {
dir := t.TempDir()
zipPath := filepath.Join(dir, "nested.zip")
err := zipDirectory(dir, zipPath)
if err == nil {
t.Fatal("expected error when zip path is inside source")
}
}