MCPcopy Create free account
hub / github.com/astercloud/aster / TestChainToJSON

Function TestChainToJSON

pkg/reasoning/reasoning_test.go:189–220  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

187}
188
189func TestChainToJSON(t *testing.T) {
190 chain := NewChain(ChainConfig{
191 MinSteps: 2,
192 MaxSteps: 5,
193 })
194
195 if err := chain.AddStep(Step{
196 Title: "Test Step",
197 Confidence: 0.9,
198 }); err != nil {
199 t.Fatalf("AddStep failed: %v", err)
200 }
201
202 jsonStr, err := chain.ToJSON()
203 if err != nil {
204 t.Fatalf("ToJSON failed: %v", err)
205 }
206
207 if jsonStr == "" {
208 t.Error("JSON string should not be empty")
209 }
210
211 // 尝试解析回来
212 parsed, err := FromJSON(jsonStr)
213 if err != nil {
214 t.Fatalf("FromJSON failed: %v", err)
215 }
216
217 if len(parsed.Steps) != 1 {
218 t.Errorf("expected 1 step after parsing, got %d", len(parsed.Steps))
219 }
220}
221
222func TestUpdateStep(t *testing.T) {
223 chain := NewChain(ChainConfig{MaxSteps: 5})

Callers

nothing calls this directly

Calls 5

AddStepMethod · 0.95
ToJSONMethod · 0.95
NewChainFunction · 0.85
FromJSONFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected