()
| 648 | |
| 649 | #[tokio::test] |
| 650 | async fn test_mock() { |
| 651 | let env = Env::new(); |
| 652 | let fs = Fs::new(); |
| 653 | let mut database = crate::database::Database::new().await.unwrap(); |
| 654 | let mut client = ApiClient::new(&env, &fs, &mut database, None).await.unwrap(); |
| 655 | client |
| 656 | .send_telemetry_event( |
| 657 | TelemetryEvent::ChatAddMessageEvent( |
| 658 | ChatAddMessageEvent::builder() |
| 659 | .conversation_id("<conversation-id>") |
| 660 | .message_id("<message-id>") |
| 661 | .build() |
| 662 | .unwrap(), |
| 663 | ), |
| 664 | UserContext::builder() |
| 665 | .ide_category(IdeCategory::Cli) |
| 666 | .operating_system(OperatingSystem::Linux) |
| 667 | .product("<product>") |
| 668 | .build() |
| 669 | .unwrap(), |
| 670 | false, |
| 671 | Some("model".to_owned()), |
| 672 | ) |
| 673 | .await |
| 674 | .unwrap(); |
| 675 | |
| 676 | client.mock_client = Some(Arc::new(Mutex::new( |
| 677 | vec![vec![ |
| 678 | ChatResponseStream::AssistantResponseEvent { |
| 679 | content: "Hello!".to_owned(), |
| 680 | }, |
| 681 | ChatResponseStream::AssistantResponseEvent { |
| 682 | content: " How can I".to_owned(), |
| 683 | }, |
| 684 | ChatResponseStream::AssistantResponseEvent { |
| 685 | content: " assist you today?".to_owned(), |
| 686 | }, |
| 687 | ]] |
| 688 | .into_iter(), |
| 689 | ))); |
| 690 | |
| 691 | let mut output = client |
| 692 | .send_message(ConversationState { |
| 693 | conversation_id: None, |
| 694 | user_input_message: UserInputMessage { |
| 695 | images: None, |
| 696 | content: "Hello".into(), |
| 697 | user_input_message_context: None, |
| 698 | user_intent: None, |
| 699 | model_id: Some("model".to_owned()), |
| 700 | }, |
| 701 | history: None, |
| 702 | }) |
| 703 | .await |
| 704 | .unwrap(); |
| 705 | |
| 706 | let mut output_content = String::new(); |
| 707 | while let Some(ChatResponseStream::AssistantResponseEvent { content }) = output.recv().await.unwrap() { |
nothing calls this directly
no test coverage detected