feat(ai): add AI client with multi-provider support and UI
Some checks failed
CI Code / Check coding style (pull_request) Successful in 47s
CI Code / Check spelling (pull_request) Successful in 59s
CI Code / Code Coverage (pull_request) Failing after 1m8s
CI Code / Linux (debian) (pull_request) Failing after 2m28s
CI Code / Linux (ubuntu) (pull_request) Failing after 2m41s
CI Code / Linux (arch) (pull_request) Failing after 3m15s
Some checks failed
CI Code / Check coding style (pull_request) Successful in 47s
CI Code / Check spelling (pull_request) Successful in 59s
CI Code / Code Coverage (pull_request) Failing after 1m8s
CI Code / Linux (debian) (pull_request) Failing after 2m28s
CI Code / Linux (ubuntu) (pull_request) Failing after 2m41s
CI Code / Linux (arch) (pull_request) Failing after 3m15s
Add an AI client module that integrates with OpenAI-compatible API providers (OpenAI, Perplexity, and custom providers) to provide AI-assisted responses within the profanity client. The implementation includes: - src/ai/ai_client.c/h: Core AI client with provider management, session handling, and async HTTP request handling via libcurl. Supports per-provider API keys stored in preferences, reference- counted sessions, and conversation history tracking. - src/ui/window.c/window_list.c: New AI window type (ProfAiWin) for displaying AI conversations, with response streaming and error display capabilities. - Command integration: New `/ai` command (cmd_defs.c, cmd_funcs.c) for creating sessions, sending prompts, and managing providers. Provider autocomplete support in cmd_ac.c. - Preferences integration: API keys for providers are persisted in the preferences system (config/preferences.c). - Unit tests: 472 lines of comprehensive tests covering provider management, session lifecycle, JSON escaping, and autocomplete (tests/unittests/test_ai_client.c). Architecture decisions: - Asynchronous design: HTTP requests run on a separate thread to avoid blocking the main UI loop. Callbacks are invoked on the main thread via direct function call (profanity uses ncurses, not GLib main loop). - Reference counting: Both AIProvider and AISession use ref counting for safe shared ownership. - Response size limit: 10MB cap on HTTP responses to prevent OOM.
This commit is contained in:
472
tests/unittests/test_ai_client.c
Normal file
472
tests/unittests/test_ai_client.c
Normal file
@@ -0,0 +1,472 @@
|
||||
#include "prof_cmocka.h"
|
||||
#include "common.h"
|
||||
#include "ai/ai_client.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/* ========================================================================
|
||||
* Setup/Teardown
|
||||
* ======================================================================== */
|
||||
|
||||
int
|
||||
ai_client_setup(void** state)
|
||||
{
|
||||
ai_client_init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ai_client_teardown(void** state)
|
||||
{
|
||||
ai_client_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ========================================================================
|
||||
* Provider Management Tests
|
||||
* ======================================================================== */
|
||||
|
||||
void
|
||||
test_ai_client_init(void** state)
|
||||
{
|
||||
/* After init, default providers should exist */
|
||||
AIProvider* openai = ai_get_provider("openai");
|
||||
assert_non_null(openai);
|
||||
assert_string_equal("openai", openai->name);
|
||||
assert_string_equal("https://api.openai.com/v1/chat/completions", openai->api_url);
|
||||
|
||||
AIProvider* perplexity = ai_get_provider("perplexity");
|
||||
assert_non_null(perplexity);
|
||||
assert_string_equal("perplexity", perplexity->name);
|
||||
assert_string_equal("https://api.perplexity.ai/v1/chat/completions", perplexity->api_url);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_add_provider(void** state)
|
||||
{
|
||||
/* Add a custom provider (hash table owns ref; caller gets non-owning pointer) */
|
||||
AIProvider* provider = ai_add_provider("custom", "https://custom.api.com/v1", "my-org");
|
||||
assert_non_null(provider);
|
||||
assert_string_equal("custom", provider->name);
|
||||
assert_string_equal("https://custom.api.com/v1", provider->api_url);
|
||||
assert_string_equal("my-org", provider->org_id);
|
||||
|
||||
/* Update existing provider (returns ref; caller owns it) */
|
||||
AIProvider* updated = ai_add_provider("custom", "https://new.api.com/v1", NULL);
|
||||
assert_non_null(updated);
|
||||
assert_string_equal("https://new.api.com/v1", updated->api_url);
|
||||
assert_null(updated->org_id);
|
||||
|
||||
ai_provider_unref(updated);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_remove_provider(void** state)
|
||||
{
|
||||
/* Remove default provider should fail */
|
||||
assert_false(ai_remove_provider("nonexistent"));
|
||||
|
||||
/* Add and remove custom provider */
|
||||
ai_add_provider("temp", "https://temp.api.com/v1", NULL);
|
||||
assert_true(ai_remove_provider("temp"));
|
||||
assert_null(ai_get_provider("temp"));
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_list_providers(void** state)
|
||||
{
|
||||
GList* providers = ai_list_providers();
|
||||
assert_non_null(providers);
|
||||
assert_int_equal(2, g_list_length(providers)); /* openai and perplexity */
|
||||
|
||||
/* Free list and unref providers (ai_list_providers returns ref'd providers) */
|
||||
for (GList* l = providers; l; l = g_list_next(l)) {
|
||||
ai_provider_unref(l->data);
|
||||
}
|
||||
g_list_free(providers);
|
||||
|
||||
/* Add another provider */
|
||||
ai_add_provider("test", "https://test.api.com/v1", NULL);
|
||||
providers = ai_list_providers();
|
||||
assert_int_equal(3, g_list_length(providers));
|
||||
|
||||
/* Free list and unref providers */
|
||||
for (GList* l = providers; l; l = g_list_next(l)) {
|
||||
ai_provider_unref(l->data);
|
||||
}
|
||||
g_list_free(providers);
|
||||
}
|
||||
|
||||
/* ========================================================================
|
||||
* API Key Tests
|
||||
* ======================================================================== */
|
||||
|
||||
void
|
||||
test_ai_set_provider_key(void** state)
|
||||
{
|
||||
ai_set_provider_key("openai", "sk-test-key-123");
|
||||
{
|
||||
auto_gchar gchar* key = ai_get_provider_key("openai");
|
||||
assert_non_null(key);
|
||||
assert_string_equal("sk-test-key-123", key);
|
||||
}
|
||||
|
||||
/* Update key */
|
||||
ai_set_provider_key("openai", "sk-new-key-456");
|
||||
{
|
||||
auto_gchar gchar* key = ai_get_provider_key("openai");
|
||||
assert_string_equal("sk-new-key-456", key);
|
||||
}
|
||||
|
||||
/* Remove key */
|
||||
ai_set_provider_key("openai", NULL);
|
||||
{
|
||||
auto_gchar gchar* key = ai_get_provider_key("openai");
|
||||
assert_null(key);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_get_provider_key(void** state)
|
||||
{
|
||||
/* No key set initially */
|
||||
{
|
||||
auto_gchar gchar* key = ai_get_provider_key("openai");
|
||||
assert_null(key);
|
||||
}
|
||||
|
||||
/* Set and get key */
|
||||
ai_set_provider_key("perplexity", "pplx-abc123");
|
||||
{
|
||||
auto_gchar gchar* key = ai_get_provider_key("perplexity");
|
||||
assert_non_null(key);
|
||||
assert_string_equal("pplx-abc123", key);
|
||||
}
|
||||
|
||||
/* Wrong provider returns null */
|
||||
{
|
||||
auto_gchar gchar* key = ai_get_provider_key("openai");
|
||||
assert_null(key);
|
||||
}
|
||||
}
|
||||
|
||||
/* ========================================================================
|
||||
* Session Tests
|
||||
* ======================================================================== */
|
||||
|
||||
void
|
||||
test_ai_session_create(void** state)
|
||||
{
|
||||
AISession* session = ai_session_create("openai", "gpt-4");
|
||||
assert_non_null(session);
|
||||
assert_string_equal("openai", session->provider_name);
|
||||
assert_string_equal("gpt-4", session->model);
|
||||
assert_null(session->api_key); /* No key set */
|
||||
|
||||
ai_session_unref(session);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_session_ref_unref(void** state)
|
||||
{
|
||||
AISession* session = ai_session_create("openai", "gpt-4");
|
||||
assert_non_null(session);
|
||||
|
||||
/* Reference */
|
||||
AISession* ref = ai_session_ref(session);
|
||||
assert_true(ref == session);
|
||||
|
||||
/* Unreference twice */
|
||||
ai_session_unref(session);
|
||||
ai_session_unref(ref); /* Should free here */
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_session_add_message(void** state)
|
||||
{
|
||||
AISession* session = ai_session_create("openai", "gpt-4");
|
||||
assert_non_null(session);
|
||||
|
||||
ai_session_add_message(session, "user", "Hello");
|
||||
ai_session_add_message(session, "assistant", "Hi there!");
|
||||
|
||||
assert_int_equal(2, g_list_length(session->history));
|
||||
|
||||
AIMessage* first = session->history->data;
|
||||
assert_string_equal("user", first->role);
|
||||
assert_string_equal("Hello", first->content);
|
||||
|
||||
AIMessage* second = g_list_next(session->history)->data;
|
||||
assert_string_equal("assistant", second->role);
|
||||
assert_string_equal("Hi there!", second->content);
|
||||
|
||||
ai_session_unref(session);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_session_clear_history(void** state)
|
||||
{
|
||||
AISession* session = ai_session_create("openai", "gpt-4");
|
||||
|
||||
ai_session_add_message(session, "user", "Message 1");
|
||||
ai_session_add_message(session, "user", "Message 2");
|
||||
ai_session_add_message(session, "assistant", "Response");
|
||||
|
||||
assert_int_equal(3, g_list_length(session->history));
|
||||
|
||||
ai_session_clear_history(session);
|
||||
assert_int_equal(0, g_list_length(session->history));
|
||||
|
||||
ai_session_unref(session);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_session_set_model(void** state)
|
||||
{
|
||||
AISession* session = ai_session_create("openai", "gpt-4");
|
||||
assert_string_equal("gpt-4", session->model);
|
||||
|
||||
ai_session_set_model(session, "gpt-3.5-turbo");
|
||||
assert_string_equal("gpt-3.5-turbo", session->model);
|
||||
|
||||
ai_session_unref(session);
|
||||
}
|
||||
|
||||
/* ========================================================================
|
||||
* JSON Escape Tests
|
||||
* ======================================================================== */
|
||||
|
||||
void
|
||||
test_ai_json_escape(void** state)
|
||||
{
|
||||
gchar* escaped = ai_json_escape("hello \"world\"");
|
||||
assert_string_equal("hello \\\"world\\\"", escaped);
|
||||
g_free(escaped);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_json_escape_null(void** state)
|
||||
{
|
||||
gchar* escaped = ai_json_escape(NULL);
|
||||
assert_string_equal("", escaped);
|
||||
g_free(escaped);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_json_escape_empty(void** state)
|
||||
{
|
||||
gchar* escaped = ai_json_escape("");
|
||||
assert_string_equal("", escaped);
|
||||
g_free(escaped);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_json_escape_special_chars(void** state)
|
||||
{
|
||||
gchar* escaped = ai_json_escape("line1\nline2\ttab\\backslash\"quote");
|
||||
assert_string_equal("line1\\nline2\\ttab\\\\backslash\\\"quote", escaped);
|
||||
g_free(escaped);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_json_escape_percent_signs(void** state)
|
||||
{
|
||||
/* Critical: % characters in content must be escaped for JSON, not treated as format specifiers */
|
||||
gchar* escaped = ai_json_escape("100% complete with %s and %d format strings");
|
||||
assert_string_equal("100% complete with %s and %d format strings", escaped);
|
||||
g_free(escaped);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_json_escape_backslash_quote(void** state)
|
||||
{
|
||||
/* Test escaped quote handling */
|
||||
gchar* escaped = ai_json_escape("He said \"hello\" and \\ goodbye");
|
||||
assert_string_equal("He said \\\"hello\\\" and \\\\ goodbye", escaped);
|
||||
g_free(escaped);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_session_api_key_is_copied(void** state)
|
||||
{
|
||||
/* Verify that session owns its own copy of the API key */
|
||||
ai_set_provider_key("openai", "sk-test-key-123");
|
||||
|
||||
AISession* session = ai_session_create("openai", "gpt-4");
|
||||
assert_non_null(session);
|
||||
assert_string_equal("sk-test-key-123", session->api_key);
|
||||
|
||||
/* Remove the provider key - session should still have its copy */
|
||||
ai_set_provider_key("openai", NULL);
|
||||
assert_non_null(session->api_key);
|
||||
assert_string_equal("sk-test-key-123", session->api_key);
|
||||
|
||||
ai_session_unref(session);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_add_provider_update_existing(void** state)
|
||||
{
|
||||
/* Add a provider (hash table owns ref) */
|
||||
AIProvider* provider = ai_add_provider("custom", "https://first.api.com/v1", "org1");
|
||||
assert_non_null(provider);
|
||||
assert_string_equal("https://first.api.com/v1", provider->api_url);
|
||||
assert_string_equal("org1", provider->org_id);
|
||||
|
||||
/* Update the same provider (returns ref) */
|
||||
provider = ai_add_provider("custom", "https://second.api.com/v1", "org2");
|
||||
assert_non_null(provider);
|
||||
assert_string_equal("https://second.api.com/v1", provider->api_url);
|
||||
assert_string_equal("org2", provider->org_id);
|
||||
ai_provider_unref(provider);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_add_provider_null_name_returns_null(void** state)
|
||||
{
|
||||
assert_null(ai_add_provider(NULL, "https://api.com/v1", NULL));
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_add_provider_null_url_returns_null(void** state)
|
||||
{
|
||||
assert_null(ai_add_provider("test", NULL, NULL));
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_session_create_null_provider_returns_null(void** state)
|
||||
{
|
||||
assert_null(ai_session_create("nonexistent", "gpt-4"));
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_session_create_null_model_returns_null(void** state)
|
||||
{
|
||||
assert_null(ai_session_create("openai", NULL));
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_session_api_key_null_when_no_key_set(void** state)
|
||||
{
|
||||
/* openai has no key set by default */
|
||||
AISession* session = ai_session_create("openai", "gpt-4");
|
||||
assert_non_null(session);
|
||||
assert_null(session->api_key);
|
||||
ai_session_unref(session);
|
||||
}
|
||||
|
||||
/* ========================================================================
|
||||
* Provider Autocomplete Tests
|
||||
* ======================================================================== */
|
||||
|
||||
void
|
||||
test_ai_providers_find_forward(void** state)
|
||||
{
|
||||
/* Test forward iteration - should return first match */
|
||||
char* result = ai_providers_find("o", FALSE, NULL);
|
||||
assert_non_null(result);
|
||||
assert_string_equal("openai", result);
|
||||
g_free(result);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_providers_find_forward_perplexity(void** state)
|
||||
{
|
||||
/* Test forward iteration for perplexity */
|
||||
char* result = ai_providers_find("p", FALSE, NULL);
|
||||
assert_non_null(result);
|
||||
assert_string_equal("perplexity", result);
|
||||
g_free(result);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_providers_find_forward_custom(void** state)
|
||||
{
|
||||
/* Add a custom provider and test */
|
||||
ai_add_provider("custom", "https://custom.api.com/v1", NULL);
|
||||
|
||||
char* result = ai_providers_find("c", FALSE, NULL);
|
||||
assert_non_null(result);
|
||||
assert_string_equal("custom", result);
|
||||
g_free(result);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_providers_find_forward_no_match(void** state)
|
||||
{
|
||||
/* Test no match */
|
||||
char* result = ai_providers_find("z", FALSE, NULL);
|
||||
assert_null(result);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_providers_find_forward_partial_match(void** state)
|
||||
{
|
||||
/* Test partial match - should return providers starting with "ope" */
|
||||
char* result = ai_providers_find("ope", FALSE, NULL);
|
||||
assert_non_null(result);
|
||||
assert_string_equal("openai", result);
|
||||
g_free(result);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_providers_find_next(void** state)
|
||||
{
|
||||
/* Test that stateless implementation returns same result each call */
|
||||
char* result1 = ai_providers_find("o", FALSE, NULL);
|
||||
assert_non_null(result1);
|
||||
assert_string_equal("openai", result1);
|
||||
g_free(result1);
|
||||
|
||||
/* Second call with same params returns same result (stateless) */
|
||||
char* result2 = ai_providers_find("o", FALSE, NULL);
|
||||
assert_non_null(result2);
|
||||
assert_string_equal("openai", result2);
|
||||
g_free(result2);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_providers_find_previous(void** state)
|
||||
{
|
||||
/* Test that previous=TRUE returns last match in list */
|
||||
/* With only "openai" starting with "o", both FALSE and TRUE return same result */
|
||||
char* result1 = ai_providers_find("o", FALSE, NULL);
|
||||
assert_non_null(result1);
|
||||
assert_string_equal("openai", result1);
|
||||
g_free(result1);
|
||||
|
||||
/* previous=TRUE also returns "openai" (only one match, so first==last) */
|
||||
char* result2 = ai_providers_find("o", TRUE, NULL);
|
||||
assert_non_null(result2);
|
||||
assert_string_equal("openai", result2);
|
||||
g_free(result2);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_providers_find_null_search_str(void** state)
|
||||
{
|
||||
char* result = ai_providers_find(NULL, FALSE, NULL);
|
||||
assert_null(result);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_providers_find_empty_search_str(void** state)
|
||||
{
|
||||
char* result = ai_providers_find("", FALSE, NULL);
|
||||
assert_null(result);
|
||||
}
|
||||
|
||||
void
|
||||
test_ai_providers_find_case_sensitive(void** state)
|
||||
{
|
||||
/* Test that matching is case-sensitive */
|
||||
char* result = ai_providers_find("OPENAI", FALSE, NULL);
|
||||
assert_null(result);
|
||||
|
||||
result = ai_providers_find("OpenAI", FALSE, NULL);
|
||||
assert_null(result);
|
||||
|
||||
result = ai_providers_find("openai", FALSE, NULL);
|
||||
assert_non_null(result);
|
||||
assert_string_equal("openai", result);
|
||||
g_free(result);
|
||||
}
|
||||
42
tests/unittests/test_ai_client.h
Normal file
42
tests/unittests/test_ai_client.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* test_ai_client.h - AI client unit test declarations
|
||||
*/
|
||||
|
||||
int ai_client_setup(void** state);
|
||||
int ai_client_teardown(void** state);
|
||||
|
||||
void test_ai_client_init(void** state);
|
||||
void test_ai_add_provider(void** state);
|
||||
void test_ai_remove_provider(void** state);
|
||||
void test_ai_list_providers(void** state);
|
||||
void test_ai_set_provider_key(void** state);
|
||||
void test_ai_get_provider_key(void** state);
|
||||
void test_ai_session_create(void** state);
|
||||
void test_ai_session_ref_unref(void** state);
|
||||
void test_ai_session_add_message(void** state);
|
||||
void test_ai_session_clear_history(void** state);
|
||||
void test_ai_session_set_model(void** state);
|
||||
void test_ai_json_escape(void** state);
|
||||
void test_ai_json_escape_null(void** state);
|
||||
void test_ai_json_escape_empty(void** state);
|
||||
void test_ai_json_escape_special_chars(void** state);
|
||||
void test_ai_json_escape_percent_signs(void** state);
|
||||
void test_ai_json_escape_backslash_quote(void** state);
|
||||
void test_ai_session_api_key_is_copied(void** state);
|
||||
void test_ai_add_provider_update_existing(void** state);
|
||||
void test_ai_add_provider_null_name_returns_null(void** state);
|
||||
void test_ai_add_provider_null_url_returns_null(void** state);
|
||||
void test_ai_session_create_null_provider_returns_null(void** state);
|
||||
void test_ai_session_create_null_model_returns_null(void** state);
|
||||
void test_ai_session_api_key_null_when_no_key_set(void** state);
|
||||
/* Provider autocomplete tests */
|
||||
void test_ai_providers_find_forward(void** state);
|
||||
void test_ai_providers_find_forward_perplexity(void** state);
|
||||
void test_ai_providers_find_forward_custom(void** state);
|
||||
void test_ai_providers_find_forward_no_match(void** state);
|
||||
void test_ai_providers_find_forward_partial_match(void** state);
|
||||
void test_ai_providers_find_next(void** state);
|
||||
void test_ai_providers_find_previous(void** state);
|
||||
void test_ai_providers_find_null_search_str(void** state);
|
||||
void test_ai_providers_find_empty_search_str(void** state);
|
||||
void test_ai_providers_find_case_sensitive(void** state);
|
||||
30
tests/unittests/ui/stub_ai.c
Normal file
30
tests/unittests/ui/stub_ai.c
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* stub_ai.c - Stubs for AI window functions
|
||||
*/
|
||||
|
||||
#include "ui/window.h"
|
||||
#include "ai/ai_client.h"
|
||||
|
||||
ProfWin*
|
||||
win_create_ai(AISession* session)
|
||||
{
|
||||
/* Return NULL to simulate failure in unit tests */
|
||||
(void)session;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
aiwin_display_response(ProfAiWin* win, const char* response)
|
||||
{
|
||||
/* Stub: do nothing */
|
||||
(void)win;
|
||||
(void)response;
|
||||
}
|
||||
|
||||
void
|
||||
aiwin_display_error(ProfAiWin* win, const char* error_msg)
|
||||
{
|
||||
/* Stub: do nothing */
|
||||
(void)win;
|
||||
(void)error_msg;
|
||||
}
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "test_form.h"
|
||||
#include "test_callbacks.h"
|
||||
#include "test_plugins_disco.h"
|
||||
#include "test_ai_client.h"
|
||||
|
||||
#define muc_unit_test(f) cmocka_unit_test_setup_teardown(f, muc_before_test, muc_after_test)
|
||||
|
||||
@@ -656,6 +657,43 @@ main(int argc, char* argv[])
|
||||
cmocka_unit_test_setup_teardown(test_allow_unencrypted_message_confirms_on_second_attempt, load_preferences, close_preferences),
|
||||
cmocka_unit_test_setup_teardown(test_cmd_force_encryption_invalid_policy, load_preferences, close_preferences),
|
||||
cmocka_unit_test_setup_teardown(test_allow_unencrypted_message_invalid_mode, load_preferences, close_preferences),
|
||||
|
||||
// AI client tests
|
||||
cmocka_unit_test_setup_teardown(test_ai_client_init, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_add_provider, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_remove_provider, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_list_providers, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_set_provider_key, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_get_provider_key, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_session_create, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_session_ref_unref, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_session_add_message, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_session_clear_history, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_session_set_model, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_session_api_key_is_copied, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_add_provider_update_existing, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_add_provider_null_name_returns_null, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_add_provider_null_url_returns_null, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_session_create_null_provider_returns_null, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_session_create_null_model_returns_null, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_session_api_key_null_when_no_key_set, ai_client_setup, ai_client_teardown),
|
||||
/* Provider autocomplete tests */
|
||||
cmocka_unit_test_setup_teardown(test_ai_providers_find_forward, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_providers_find_forward_perplexity, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_providers_find_forward_custom, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_providers_find_forward_no_match, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_providers_find_forward_partial_match, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_providers_find_next, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_providers_find_previous, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_providers_find_null_search_str, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_providers_find_empty_search_str, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test_setup_teardown(test_ai_providers_find_case_sensitive, ai_client_setup, ai_client_teardown),
|
||||
cmocka_unit_test(test_ai_json_escape),
|
||||
cmocka_unit_test(test_ai_json_escape_null),
|
||||
cmocka_unit_test(test_ai_json_escape_empty),
|
||||
cmocka_unit_test(test_ai_json_escape_special_chars),
|
||||
cmocka_unit_test(test_ai_json_escape_percent_signs),
|
||||
cmocka_unit_test(test_ai_json_escape_backslash_quote),
|
||||
};
|
||||
return cmocka_run_group_tests(all_tests, NULL, NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user