(t *testing.T)
| 549 | } |
| 550 | |
| 551 | func TestRecordInterception(t *testing.T) { |
| 552 | t.Parallel() |
| 553 | |
| 554 | var ( |
| 555 | metadataProto = map[string]*anypb.Any{ |
| 556 | "key": mustMarshalAny(t, &structpb.Value{Kind: &structpb.Value_StringValue{StringValue: "value"}}), |
| 557 | } |
| 558 | metadataJSON = `{"key":"value"}` |
| 559 | ) |
| 560 | |
| 561 | testRecordMethod(t, |
| 562 | func(srv *aibridgedserver.Server, ctx context.Context, req *proto.RecordInterceptionRequest) (*proto.RecordInterceptionResponse, error) { |
| 563 | return srv.RecordInterception(ctx, req) |
| 564 | }, |
| 565 | []testRecordMethodCase[*proto.RecordInterceptionRequest]{ |
| 566 | { |
| 567 | name: "valid interception", |
| 568 | request: &proto.RecordInterceptionRequest{ |
| 569 | Id: uuid.NewString(), |
| 570 | ApiKeyId: uuid.NewString(), |
| 571 | InitiatorId: uuid.NewString(), |
| 572 | Provider: "anthropic", |
| 573 | ProviderName: "anthropic", |
| 574 | Model: "claude-4-opus", |
| 575 | Metadata: metadataProto, |
| 576 | StartedAt: timestamppb.Now(), |
| 577 | CredentialKind: "byok", |
| 578 | CredentialHint: "sk-a...efgh", |
| 579 | }, |
| 580 | setupMocks: func(t *testing.T, db *dbmock.MockStore, req *proto.RecordInterceptionRequest) { |
| 581 | interceptionID, err := uuid.Parse(req.GetId()) |
| 582 | assert.NoError(t, err, "parse interception UUID") |
| 583 | initiatorID, err := uuid.Parse(req.GetInitiatorId()) |
| 584 | assert.NoError(t, err, "parse interception initiator UUID") |
| 585 | |
| 586 | db.EXPECT().InsertAIBridgeInterception(gomock.Any(), database.InsertAIBridgeInterceptionParams{ |
| 587 | ID: interceptionID, |
| 588 | APIKeyID: sql.NullString{String: req.ApiKeyId, Valid: true}, |
| 589 | InitiatorID: initiatorID, |
| 590 | Provider: req.GetProvider(), |
| 591 | ProviderName: req.GetProviderName(), |
| 592 | Model: req.GetModel(), |
| 593 | Metadata: json.RawMessage(metadataJSON), |
| 594 | StartedAt: req.StartedAt.AsTime().UTC(), |
| 595 | CredentialKind: database.CredentialKindByok, |
| 596 | CredentialHint: "sk-a...efgh", |
| 597 | }).Return(database.AIBridgeInterception{ |
| 598 | ID: interceptionID, |
| 599 | APIKeyID: sql.NullString{String: req.ApiKeyId, Valid: true}, |
| 600 | InitiatorID: initiatorID, |
| 601 | Provider: req.GetProvider(), |
| 602 | ProviderName: req.GetProviderName(), |
| 603 | Model: req.GetModel(), |
| 604 | StartedAt: req.StartedAt.AsTime().UTC(), |
| 605 | CredentialKind: database.CredentialKindByok, |
| 606 | CredentialHint: "sk-a...efgh", |
| 607 | }, nil) |
| 608 | }, |
nothing calls this directly
no test coverage detected