//go:build !cgo package backend import ( "context" "testing" ) // TestStartHeartbeat_StubNoOp verifies the no-CGO stub for StartHeartbeat // is a no-op that does not panic or return an error. func TestStartHeartbeat_StubNoOp(t *testing.T) { // Should not panic and completes immediately StartHeartbeat(context.Background()) } // TestEvalSelectForHost_StubErrNoCGO verifies the no-CGO stub for // EvalSelectForHost returns errNoCGO, blocking callers from using // select expressions without the real CGO backend. func TestEvalSelectForHost_StubErrNoCGO(t *testing.T) { err := EvalSelectForHost("host01", "mem>4") if err != errNoCGO { t.Errorf("EvalSelectForHost stub should return errNoCGO, got %v", err) } } // TestCleanup_StubNoOp verifies the no-CGO stub for Cleanup // is a no-op that does not panic (the real CGO version frees C resources). func TestCleanup_StubNoOp(t *testing.T) { // Should not panic and completes immediately Cleanup() } // TestRegisterToBackend_StubSingleHost verifies the stub returns errNoCGO // for a single-host BackendConfig (no Peers). func TestRegisterToBackend_StubSingleHost(t *testing.T) { err := RegisterToBackend(&BackendConfig{ Address: "ctrl01", Port: 9990, From: "xce_apiserver", Key: "keepsecret$", }) if err != errNoCGO { t.Errorf("expected errNoCGO, got %v", err) } } // TestRegisterToBackend_StubWithPeers verifies the stub returns errNoCGO // even when Peers are configured (HA mode), since CGO is not available. func TestRegisterToBackend_StubWithPeers(t *testing.T) { err := RegisterToBackend(&BackendConfig{ Peers: []string{"ctrl01:9990", "ctrl02:9990"}, From: "xce_apiserver", Key: "keepsecret$", }) if err != errNoCGO { t.Errorf("expected errNoCGO with peers configured, got %v", err) } }