Files
AetherForge/server/internal/api/deploy_plan_cloudmap_test.go
AetherForge bcd25b53a6
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Fix server feature tests and refresh Go Test* counts.
Unskip cloud-map export assertions, correct cloud venue class fixtures, and update tests/README.md to 960 server / 670 agent Test* totals.
2026-06-07 11:11:30 -07:00

58 lines
1.7 KiB
Go

package api
import (
"bytes"
"encoding/json"
"net/http"
"net/http/httptest"
"strings"
"testing"
"crypto-miner-server/internal/cloudmap"
)
func TestCloudTemplatePathsCloudMap(t *testing.T) {
subdir, zip, err := cloudTemplatePaths("cloud-map")
if err != nil || subdir != "cloud-map" || zip != "aetherforge-cloud-map.zip" {
t.Fatalf("subdir=%q zip=%q err=%v", subdir, zip, err)
}
}
func TestExportCloudMapTemplateZIP(t *testing.T) {
root := integrationWorkspaceRoot(t)
h := NewSpreadHandler(nil, t.TempDir(), root, nil)
body, _ := json.Marshal(map[string]interface{}{
"template": "cloud-map",
"server_url": "https://deck.example",
"build_id": "pin-map",
"campaign": "map-wave",
"namespace_name": "aether.local",
"region": "us-east-1",
})
req := httptest.NewRequest(http.MethodPost, "/api/v1/builder/cloud-template-export", bytes.NewReader(body))
rec := httptest.NewRecorder()
h.ExportCloudTemplate(rec, req)
if rec.Code != http.StatusOK {
t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String())
}
entries := readZipEntries(t, rec.Body.Bytes())
if !strings.Contains(entries["service-registry.json"], "aetherforge-seeder") {
t.Fatalf("service-registry.json=%s", entries["service-registry.json"])
}
}
func TestCloudMapKnowNodeTargetsFromRegistry(t *testing.T) {
doc := cloudmap.RegistryDocument{
Namespace: "prod.local",
Service: "seeder",
Instances: []cloudmap.RegistryInstance{
{AgentID: "agent-a", Healthy: true},
{DNSName: "seeder.svc.prod.local", Healthy: true},
},
}
targets := cloudmap.KnowNodeTargets(doc)
if len(targets) != 2 || targets[0] != "agent-a" {
t.Fatalf("targets=%v", targets)
}
}