Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 43 additions & 14 deletions test/test_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ TEST_SUITE("xassist"){

}

TEST_CASE("gemini_save"){
TEST_CASE("gemini"){
xcpp::xassist assist;
std::string line = "%%xassist gemini --save-key";
std::string cell = "1234";
Expand All @@ -918,25 +918,39 @@ TEST_SUITE("xassist"){
REQUIRE(content == "1234");
infile.close();

line = "%%xassist gemini --save-model";
cell = "1234";

assist(line, cell);

std::ifstream infile_model("gemini_model.txt");
std::string content_model;
std::getline(infile_model, content_model);

REQUIRE(content_model == "1234");
infile_model.close();

StreamRedirectRAII redirect(std::cerr);

assist("%%xassist gemini", "hello");

REQUIRE(!redirect.getCaptured().empty());

std::remove("gemini_api_key.txt");
}
line = "%%xassist gemini --refresh";
cell = "";

TEST_CASE("gemini"){
xcpp::xassist assist;
std::string line = "%%xassist gemini";
std::string cell = "hello";
assist(line, cell);

StreamRedirectRAII redirect(std::cerr);
std::ifstream infile_chat("gemini_chat_history.txt");
std::string content_chat;
std::getline(infile_chat, content_chat);

assist(line, cell);
REQUIRE(content_chat == "");
infile_chat.close();

REQUIRE(!redirect.getCaptured().empty());
std::remove("gemini_api_key.txt");
std::remove("gemini_model.txt");
std::remove("gemini_chat_history.txt");
}

TEST_CASE("openai"){
Expand All @@ -953,27 +967,41 @@ TEST_SUITE("xassist"){
REQUIRE(content == "1234");
infile.close();

line = "%%xassist openai --save-model";
cell = "1234";

assist(line, cell);

std::ifstream infile_model("openai_model.txt");
std::string content_model;
std::getline(infile_model, content_model);

REQUIRE(content_model == "1234");
infile_model.close();

StreamRedirectRAII redirect(std::cerr);

assist("%%xassist openai", "hello");

REQUIRE(!redirect.getCaptured().empty());

std::remove("openai_api_key.txt");
std::remove("openai_model.txt");
std::remove("openai_chat_history.txt");
}

TEST_CASE("ollama"){
xcpp::xassist assist;
std::string line = "%%xassist ollama --set-url";
std::string cell = "1234";
std::string cell = "https://api.openai.com/v1/chat/completions";

assist(line, cell);

std::ifstream infile("ollama_url.txt");
std::string content;
std::getline(infile, content);

REQUIRE(content == "1234");
REQUIRE(content == "https://api.openai.com/v1/chat/completions");
infile.close();

line = "%%xassist ollama --save-model";
Expand All @@ -990,11 +1018,12 @@ TEST_SUITE("xassist"){

StreamRedirectRAII redirect(std::cerr);

assist("%%xassist openai", "hello");
assist("%%xassist ollama", "hello");

REQUIRE(!redirect.getCaptured().empty());

std::remove("openai_api_key.txt");
std::remove("ollama_url.txt");
std::remove("ollama_model.txt");
}

}