@@ -904,7 +904,7 @@ TEST_SUITE("xassist"){
904
904
905
905
}
906
906
907
- TEST_CASE (" gemini_save " ){
907
+ TEST_CASE (" gemini " ){
908
908
xcpp::xassist assist;
909
909
std::string line = " %%xassist gemini --save-key" ;
910
910
std::string cell = " 1234" ;
@@ -918,25 +918,39 @@ TEST_SUITE("xassist"){
918
918
REQUIRE (content == " 1234" );
919
919
infile.close ();
920
920
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
+
921
933
StreamRedirectRAII redirect (std::cerr);
922
934
923
935
assist (" %%xassist gemini" , " hello" );
924
936
925
937
REQUIRE (!redirect.getCaptured ().empty ());
926
938
927
- std::remove ( " gemini_api_key.txt " ) ;
928
- }
939
+ line = " %%xassist gemini --refresh " ;
940
+ cell = " " ;
929
941
930
- TEST_CASE (" gemini" ){
931
- xcpp::xassist assist;
932
- std::string line = " %%xassist gemini" ;
933
- std::string cell = " hello" ;
942
+ assist (line, cell);
934
943
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);
936
947
937
- assist (line, cell);
948
+ REQUIRE (content_chat == " " );
949
+ infile_chat.close ();
938
950
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" );
940
954
}
941
955
942
956
TEST_CASE (" openai" ){
@@ -953,27 +967,41 @@ TEST_SUITE("xassist"){
953
967
REQUIRE (content == " 1234" );
954
968
infile.close ();
955
969
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
+
956
982
StreamRedirectRAII redirect (std::cerr);
957
983
958
984
assist (" %%xassist openai" , " hello" );
959
985
960
986
REQUIRE (!redirect.getCaptured ().empty ());
961
987
962
988
std::remove (" openai_api_key.txt" );
989
+ std::remove (" openai_model.txt" );
990
+ std::remove (" openai_chat_history.txt" );
963
991
}
964
992
965
993
TEST_CASE (" ollama" ){
966
994
xcpp::xassist assist;
967
995
std::string line = " %%xassist ollama --set-url" ;
968
- std::string cell = " 1234 " ;
996
+ std::string cell = " https://api.openai.com/v1/chat/completions " ;
969
997
970
998
assist (line, cell);
971
999
972
1000
std::ifstream infile (" ollama_url.txt" );
973
1001
std::string content;
974
1002
std::getline (infile, content);
975
1003
976
- REQUIRE (content == " 1234 " );
1004
+ REQUIRE (content == " https://api.openai.com/v1/chat/completions " );
977
1005
infile.close ();
978
1006
979
1007
line = " %%xassist ollama --save-model" ;
@@ -990,11 +1018,12 @@ TEST_SUITE("xassist"){
990
1018
991
1019
StreamRedirectRAII redirect (std::cerr);
992
1020
993
- assist (" %%xassist openai " , " hello" );
1021
+ assist (" %%xassist ollama " , " hello" );
994
1022
995
1023
REQUIRE (!redirect.getCaptured ().empty ());
996
1024
997
- std::remove (" openai_api_key.txt" );
1025
+ std::remove (" ollama_url.txt" );
1026
+ std::remove (" ollama_model.txt" );
998
1027
}
999
1028
1000
1029
}
0 commit comments