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

Function TestAPIDispatcher_StatusAndConfig

internal/nodeagent/dispatch_test.go:43–69  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

41}
42
43func TestAPIDispatcher_StatusAndConfig(t *testing.T) {
44 t.Parallel()
45 d := NewAPIDispatcher(newTestAPI(), nil)
46 ctx := context.Background()
47
48 body, err := d.Handle(ctx, "Status", nil)
49 if err != nil {
50 t.Fatalf("Status err: %v", err)
51 }
52 var st struct {
53 Running bool `json:"running"`
54 }
55 if err := json.Unmarshal(body, &st); err != nil {
56 t.Fatalf("decode status: %v body=%s", err, body)
57 }
58
59 body, err = d.Handle(ctx, "Config", nil)
60 if err != nil {
61 t.Fatalf("Config err: %v", err)
62 }
63 var cfg struct {
64 Config string `json:"config"`
65 }
66 if err := json.Unmarshal(body, &cfg); err != nil {
67 t.Fatalf("decode config: %v", err)
68 }
69}
70
71func TestAPIDispatcher_Usage(t *testing.T) {
72 t.Parallel()

Callers

nothing calls this directly

Calls 3

HandleMethod · 0.95
NewAPIDispatcherFunction · 0.85
newTestAPIFunction · 0.85

Tested by

no test coverage detected