Files
base/cmd/cli/cluster_test.go
zeekay 9fbfc287eb cli: first-class base CLI subcommands inherited by all Base daemons
Adds collection/record/login/whoami/crons + daemon lifecycle +
cluster (base-ha HA) + operator (K8s CRD) + config/status/self/rpc.
Lux/cli network flags (--mainnet/--testnet/--devnet/--dev).

All Base daemons (atsd-style binaries) get the full CLI for free
via base.Start() or manual cmd.AddCommand(cmd.NewCLICommand()).
2026-04-13 13:29:39 -07:00

59 lines
1.5 KiB
Go

package cli
import (
"strings"
"testing"
)
func TestHaConfigPath(t *testing.T) {
t.Parallel()
got := haConfigPath("ats", EnvMainnet)
if !strings.HasSuffix(got, "ha-ats-mainnet.yaml") {
t.Fatalf("expected ha-ats-mainnet.yaml suffix, got %s", got)
}
got = haConfigPath("bd", EnvLocal)
if !strings.HasSuffix(got, "ha-bd-local.yaml") {
t.Fatalf("expected ha-bd-local.yaml suffix, got %s", got)
}
}
func TestHaConfigContent(t *testing.T) {
t.Parallel()
content := haConfigContent("ats", EnvLocal, "lux", 3)
if !strings.Contains(content, "daemon: ats") {
t.Fatalf("expected daemon name in config, got:\n%s", content)
}
if !strings.Contains(content, "consensus: lux") {
t.Fatalf("expected consensus in config, got:\n%s", content)
}
if !strings.Contains(content, "replicas: 3") {
t.Fatalf("expected replicas in config, got:\n%s", content)
}
if !strings.Contains(content, "http://127.0.0.1:8090") {
t.Fatalf("expected first peer in config, got:\n%s", content)
}
if !strings.Contains(content, "http://127.0.0.1:8092") {
t.Fatalf("expected third peer in config, got:\n%s", content)
}
}
func TestHaConfigContentPubsub(t *testing.T) {
t.Parallel()
content := haConfigContent("bd", EnvTestnet, "pubsub", 5)
if !strings.Contains(content, "consensus: pubsub") {
t.Fatalf("expected pubsub consensus, got:\n%s", content)
}
if !strings.Contains(content, "replicas: 5") {
t.Fatalf("expected 5 replicas, got:\n%s", content)
}
if !strings.Contains(content, "http://127.0.0.1:8094") {
t.Fatalf("expected fifth peer in config, got:\n%s", content)
}
}