初版功能完成
ci / Go checks (ubuntu-latest) (push) Has been cancelled
ci / Go checks (windows-latest) (push) Has been cancelled

This commit is contained in:
qsc
2026-08-29 13:12:17 +08:00
commit 142e5dc7d6
217 changed files with 21313 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
//go:build windows
package main
import (
"encoding/json"
"strings"
"testing"
"remlink/internal/nodeagent"
)
func TestGetStateSerializesEmptyCollectionsAsArrays(t *testing.T) {
app := NewEngineerApp(nodeagent.Options{}, nil)
// Simulate an empty NodeList payload, which previously replaced the
// initialized slices with nil slices.
app.state.Sites = nil
app.state.Logs = nil
app.state.Session.CIDRs = nil
app.state.SiteCIDRs = nil
encoded, err := json.Marshal(app.GetState())
if err != nil {
t.Fatalf("marshal Engineer state: %v", err)
}
jsonState := string(encoded)
for _, field := range []string{`"sites":[]`, `"siteCIDRs":{}`, `"logs":[]`, `"cidrs":[]`} {
if !strings.Contains(jsonState, field) {
t.Fatalf("expected %s in state JSON, got %s", field, jsonState)
}
}
}