Fix Vitest suite and wire cloud/AWS dashboard API helpers.
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
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.
This commit is contained in:
@@ -1,35 +1,30 @@
|
||||
//go:build ignore
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"crypto-miner-server/internal/erasure"
|
||||
)
|
||||
|
||||
func TestGetS3CRRTemplate(t *testing.T) {
|
||||
h := NewSpreadHandler(nil, t.TempDir(), t.TempDir(), nil)
|
||||
h.BindS3CRRConfig(func() erasure.S3ShardConfig {
|
||||
return erasure.S3ShardConfig{
|
||||
ShardBucket: "primary", ShardRegion: "us-east-1",
|
||||
CRRDestBucket: "replica", CRRDestRegion: "eu-west-1",
|
||||
}
|
||||
})
|
||||
req := httptest.NewRequest(http.MethodGet, "/api/v1/spread/aws-s3-crr-template", nil)
|
||||
w := httptest.NewRecorder()
|
||||
h.GetS3CRRTemplate(w, req)
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("status=%d body=%s", w.Code, w.Body.String())
|
||||
}
|
||||
var body map[string]interface{}
|
||||
if err := json.Unmarshal(w.Body.Bytes(), &body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if body["rule"] == nil {
|
||||
t.Fatalf("body=%v", body)
|
||||
func TestCloudTemplatePathsS3Cloudfront(t *testing.T) {
|
||||
subdir, zip, err := cloudTemplatePaths("s3-cloudfront")
|
||||
if err != nil || subdir != "s3-cloudfront" || zip != "aetherforge-s3-cloudfront.zip" {
|
||||
t.Fatalf("subdir=%q zip=%q err=%v", subdir, zip, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildS3CRRRuleReplicationRole(t *testing.T) {
|
||||
doc, err := erasure.BuildS3CRRRule(erasure.S3ShardConfig{
|
||||
ShardBucket: "primary", ShardRegion: "us-east-1",
|
||||
CRRDestBucket: "replica", CRRDestRegion: "eu-west-1",
|
||||
ReplicationAccountID: "111122223333",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
role, _ := doc["Role"].(string)
|
||||
if !strings.Contains(role, "111122223333") {
|
||||
t.Fatalf("role=%q", role)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user