Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Adds missing client methods, VPC seeder badges, hospice strain UI, and uiHelp drift keys so server/web builds and all 849 Vitest tests pass.
58 lines
1.6 KiB
Go
58 lines
1.6 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["registry.json"], "aether.local") {
|
|
t.Fatalf("registry.json=%s", entries["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)
|
|
}
|
|
}
|