MCPcopy
hub / github.com/micro/go-micro / TestFlowStepVerificationFailureIsCheckpointed

Function TestFlowStepVerificationFailureIsCheckpointed

flow/verification_test.go:64–100  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

62}
63
64func TestFlowStepVerificationFailureIsCheckpointed(t *testing.T) {
65 step := Step{
66 Name: "grade",
67 Run: func(ctx context.Context, in State) (State, error) {
68 in.Data = []byte("bad")
69 return in, nil
70 },
71 Verify: func(ctx context.Context, out State) (Verification, error) {
72 return Verification{Feedback: "missing citation"}, nil
73 },
74 }
75
76 cp := StoreCheckpoint(store.NewMemoryStore(), "verified-fail")
77 f := New("verified-fail", WithCheckpoint(cp), Steps(step))
78 err := f.Execute(context.Background(), "question")
79 if err == nil {
80 t.Fatal("Execute succeeded, want verification failure")
81 }
82 var verr *VerificationError
83 if !errors.As(err, &verr) {
84 t.Fatalf("error = %T %v, want VerificationError", err, err)
85 }
86 if verr.Feedback != "missing citation" {
87 t.Fatalf("feedback = %q, want missing citation", verr.Feedback)
88 }
89 runs, listErr := cp.List(context.Background())
90 if listErr != nil {
91 t.Fatal(listErr)
92 }
93 if len(runs) != 1 {
94 t.Fatalf("runs = %d, want 1", len(runs))
95 }
96 stepRecord := runs[0].Steps[0]
97 if runs[0].Status != "failed" || stepRecord.VerificationStatus != "failed" || stepRecord.VerificationNote != "missing citation" {
98 t.Fatalf("run = %#v step = %#v", runs[0], stepRecord)
99 }
100}

Callers

nothing calls this directly

Calls 9

NewMemoryStoreFunction · 0.92
StepsFunction · 0.85
ExecuteMethod · 0.80
FatalMethod · 0.80
StoreCheckpointFunction · 0.70
NewFunction · 0.70
WithCheckpointFunction · 0.70
ListMethod · 0.65
FatalfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…