MCPcopy Create free account
hub / github.com/danielmiessler/Fabric / TestExtractStepOutput

Function TestExtractStepOutput

internal/cli/workflow_test.go:181–216  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

179}
180
181func TestExtractStepOutput(t *testing.T) {
182 ok := &fsdb.Session{}
183 ok.Append(&chat.ChatCompletionMessage{Role: chat.ChatMessageRoleAssistant, Content: " hello "})
184
185 blank := &fsdb.Session{}
186 blank.Append(&chat.ChatCompletionMessage{Role: chat.ChatMessageRoleAssistant, Content: " \n\t "})
187
188 tests := []struct {
189 name string
190 sess *fsdb.Session
191 want string
192 wantErr string
193 }{
194 {"trims and returns content", ok, "hello", ""},
195 {"nil session", nil, "", "no session"},
196 {"empty session", &fsdb.Session{}, "", "no message"},
197 {"whitespace only", blank, "", "empty output"},
198 }
199 for _, tc := range tests {
200 t.Run(tc.name, func(t *testing.T) {
201 out, err := extractStepOutput(tc.sess)
202 if tc.wantErr == "" {
203 if err != nil {
204 t.Fatalf("unexpected error: %v", err)
205 }
206 if out != tc.want {
207 t.Fatalf("got %q, want %q", out, tc.want)
208 }
209 return
210 }
211 if err == nil || !strings.Contains(err.Error(), tc.wantErr) {
212 t.Fatalf("got err=%v, want substring %q", err, tc.wantErr)
213 }
214 })
215 }
216}
217
218func TestResolveStepInputWithOverride(t *testing.T) {
219 carried := "previous step output"

Callers

nothing calls this directly

Calls 3

AppendMethod · 0.95
extractStepOutputFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected