@@ -904,7 +904,7 @@ TEST_SUITE("xassist"){
904904
905905 }
906906
907- TEST_CASE (" gemini_save " ){
907+ TEST_CASE (" gemini " ){
908908 xcpp::xassist assist;
909909 std::string line = " %%xassist gemini --save-key" ;
910910 std::string cell = " 1234" ;
@@ -918,25 +918,39 @@ TEST_SUITE("xassist"){
918918 REQUIRE (content == " 1234" );
919919 infile.close ();
920920
921+ line = " %%xassist gemini --save-model" ;
922+ cell = " 1234" ;
923+
924+ assist (line, cell);
925+
926+ std::ifstream infile_model (" gemini_model.txt" );
927+ std::string content_model;
928+ std::getline (infile_model, content_model);
929+
930+ REQUIRE (content_model == " 1234" );
931+ infile_model.close ();
932+
921933 StreamRedirectRAII redirect (std::cerr);
922934
923935 assist (" %%xassist gemini" , " hello" );
924936
925937 REQUIRE (!redirect.getCaptured ().empty ());
926938
927- std::remove ( " gemini_api_key.txt " ) ;
928- }
939+ line = " %%xassist gemini --refresh " ;
940+ cell = " " ;
929941
930- TEST_CASE (" gemini" ){
931- xcpp::xassist assist;
932- std::string line = " %%xassist gemini" ;
933- std::string cell = " hello" ;
942+ assist (line, cell);
934943
935- StreamRedirectRAII redirect (std::cerr);
944+ std::ifstream infile_chat (" gemini_chat_history.txt" );
945+ std::string content_chat;
946+ std::getline (infile_chat, content_chat);
936947
937- assist (line, cell);
948+ REQUIRE (content_chat == " " );
949+ infile_chat.close ();
938950
939- REQUIRE (!redirect.getCaptured ().empty ());
951+ std::remove (" gemini_api_key.txt" );
952+ std::remove (" gemini_model.txt" );
953+ std::remove (" gemini_chat_history.txt" );
940954 }
941955
942956 TEST_CASE (" openai" ){
@@ -953,27 +967,41 @@ TEST_SUITE("xassist"){
953967 REQUIRE (content == " 1234" );
954968 infile.close ();
955969
970+ line = " %%xassist openai --save-model" ;
971+ cell = " 1234" ;
972+
973+ assist (line, cell);
974+
975+ std::ifstream infile_model (" openai_model.txt" );
976+ std::string content_model;
977+ std::getline (infile_model, content_model);
978+
979+ REQUIRE (content_model == " 1234" );
980+ infile_model.close ();
981+
956982 StreamRedirectRAII redirect (std::cerr);
957983
958984 assist (" %%xassist openai" , " hello" );
959985
960986 REQUIRE (!redirect.getCaptured ().empty ());
961987
962988 std::remove (" openai_api_key.txt" );
989+ std::remove (" openai_model.txt" );
990+ std::remove (" openai_chat_history.txt" );
963991 }
964992
965993 TEST_CASE (" ollama" ){
966994 xcpp::xassist assist;
967995 std::string line = " %%xassist ollama --set-url" ;
968- std::string cell = " 1234 " ;
996+ std::string cell = " https://api.openai.com/v1/chat/completions " ;
969997
970998 assist (line, cell);
971999
9721000 std::ifstream infile (" ollama_url.txt" );
9731001 std::string content;
9741002 std::getline (infile, content);
9751003
976- REQUIRE (content == " 1234 " );
1004+ REQUIRE (content == " https://api.openai.com/v1/chat/completions " );
9771005 infile.close ();
9781006
9791007 line = " %%xassist ollama --save-model" ;
@@ -990,11 +1018,12 @@ TEST_SUITE("xassist"){
9901018
9911019 StreamRedirectRAII redirect (std::cerr);
9921020
993- assist (" %%xassist openai " , " hello" );
1021+ assist (" %%xassist ollama " , " hello" );
9941022
9951023 REQUIRE (!redirect.getCaptured ().empty ());
9961024
997- std::remove (" openai_api_key.txt" );
1025+ std::remove (" ollama_url.txt" );
1026+ std::remove (" ollama_model.txt" );
9981027 }
9991028
10001029}
0 commit comments