myxce/src/frontend/apiserver/backend/control_host_test.go
Rongsong Shen 5807a05cbb fix: address P0-2b review issues - build tag and actionType guard
1. Add //go:build !cgo to control_host_test.go so the stub-testing
   tests only run in non-CGO builds, matching the stub.go build
   constraint. Clean up dead nil check in SignatureCompiles test.

2. Replace two independent if-statements for actionType mapping in
   ControlHost with a map lookup + explicit guard, consistent with
   ControlQueue's ActionMap pattern. Prevents silent zero-value
   actionType if SupportedHostActions expands later.
2026-04-17 08:25:05 +00:00

24 lines
737 B
Go

//go:build !cgo
package backend
import (
"testing"
)
// TestControlHost_StubReturnsError verifies that in the non-CGO build the
// ControlHost function is present, accepts the expected parameters, and
// returns a non-nil error (the errNoCGO sentinel).
func TestControlHost_StubReturnsError(t *testing.T) {
err := ControlHost("node01", 1)
if err == nil {
t.Fatal("expected non-nil error from ControlHost stub")
}
}
// TestControlHost_SignatureCompiles is a compile-time check that the function
// signature matches: func ControlHost(hostname string, action int) error.
// If the signature changes this test will not compile.
func TestControlHost_SignatureCompiles(t *testing.T) {
var _ func(string, int) error = ControlHost
}