MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / TestDefaultHelloProvider

Function TestDefaultHelloProvider

internal/nodeagent/agent_test.go:482–503  ·  view source on GitHub ↗

8) DefaultHelloProvider 行为。

(t *testing.T)

Source from the content-addressed store, hash-verified

480
481// 8) DefaultHelloProvider 行为。
482func TestDefaultHelloProvider(t *testing.T) {
483 t.Parallel()
484 hp := DefaultHelloProvider("nodeA", func() string { return "abc" })
485 body, err := hp()
486 if err != nil {
487 t.Fatalf("hp err: %v", err)
488 }
489 var out struct {
490 NodeID, ConfigHash, Version string `json:"-"`
491 }
492 out.NodeID = "x"
493 if err := json.Unmarshal(body, &struct {
494 NodeID *string `json:"node_id"`
495 ConfigHash *string `json:"config_hash"`
496 Version *string `json:"version"`
497 }{&out.NodeID, &out.ConfigHash, &out.Version}); err != nil {
498 t.Fatalf("unmarshal: %v", err)
499 }
500 if out.NodeID != "nodeA" || out.ConfigHash != "abc" {
501 t.Fatalf("unexpected hello body: %+v", out)
502 }
503}
504
505// 让 mockSession 提供主动关闭流的能力。已在上方实现(closeStream)。
506var _ = io.EOF

Callers

nothing calls this directly

Calls 1

DefaultHelloProviderFunction · 0.85

Tested by

no test coverage detected