(t *testing.T)
| 179 | } |
| 180 | |
| 181 | func 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 | |
| 218 | func TestResolveStepInputWithOverride(t *testing.T) { |
| 219 | carried := "previous step output" |
nothing calls this directly
no test coverage detected