(t *testing.T)
| 1308 | } |
| 1309 | |
| 1310 | func TestRecordModelThought(t *testing.T) { |
| 1311 | t.Parallel() |
| 1312 | |
| 1313 | var ( |
| 1314 | metadataProto = map[string]*anypb.Any{ |
| 1315 | "key": mustMarshalAny(t, &structpb.Value{Kind: &structpb.Value_StringValue{StringValue: "value"}}), |
| 1316 | } |
| 1317 | metadataJSON = `{"key":"value"}` |
| 1318 | ) |
| 1319 | |
| 1320 | testRecordMethod(t, |
| 1321 | func(srv *aibridgedserver.Server, ctx context.Context, req *proto.RecordModelThoughtRequest) (*proto.RecordModelThoughtResponse, error) { |
| 1322 | return srv.RecordModelThought(ctx, req) |
| 1323 | }, |
| 1324 | []testRecordMethodCase[*proto.RecordModelThoughtRequest]{ |
| 1325 | { |
| 1326 | name: "valid model thought", |
| 1327 | request: &proto.RecordModelThoughtRequest{ |
| 1328 | InterceptionId: uuid.NewString(), |
| 1329 | Content: "I should list the files.", |
| 1330 | Metadata: metadataProto, |
| 1331 | CreatedAt: timestamppb.Now(), |
| 1332 | }, |
| 1333 | setupMocks: func(t *testing.T, db *dbmock.MockStore, req *proto.RecordModelThoughtRequest) { |
| 1334 | interceptionID, err := uuid.Parse(req.GetInterceptionId()) |
| 1335 | assert.NoError(t, err, "parse interception UUID") |
| 1336 | |
| 1337 | db.EXPECT().InsertAIBridgeModelThought(gomock.Any(), gomock.Cond(func(p database.InsertAIBridgeModelThoughtParams) bool { |
| 1338 | if !assert.Equal(t, interceptionID, p.InterceptionID, "interception ID") || |
| 1339 | !assert.Equal(t, "I should list the files.", p.Content, "content") || |
| 1340 | !assert.JSONEq(t, metadataJSON, string(p.Metadata), "metadata") { |
| 1341 | return false |
| 1342 | } |
| 1343 | return true |
| 1344 | })).Return(database.AIBridgeModelThought{ |
| 1345 | InterceptionID: interceptionID, |
| 1346 | Content: "I should list the files.", |
| 1347 | Metadata: pqtype.NullRawMessage{ |
| 1348 | RawMessage: json.RawMessage(metadataJSON), |
| 1349 | Valid: true, |
| 1350 | }, |
| 1351 | }, nil) |
| 1352 | }, |
| 1353 | }, |
| 1354 | { |
| 1355 | name: "invalid interception ID", |
| 1356 | request: &proto.RecordModelThoughtRequest{ |
| 1357 | InterceptionId: "not-a-uuid", |
| 1358 | Content: "thinking...", |
| 1359 | CreatedAt: timestamppb.Now(), |
| 1360 | }, |
| 1361 | expectedErr: "failed to parse interception_id", |
| 1362 | }, |
| 1363 | { |
| 1364 | name: "database error", |
| 1365 | request: &proto.RecordModelThoughtRequest{ |
| 1366 | InterceptionId: uuid.NewString(), |
| 1367 | Content: "thinking...", |
nothing calls this directly
no test coverage detected