mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-21 11:16:22 +00:00
Rewrote internal JSON parsing to correctly handle whitespace, escaped quotes, and strict field context extraction. This prevents incorrect field names or provider names from being added to the model list. Added `ai_parse_models_from_json` public API to facilitate testing. Changed `/ai models` default behavior to always fetch fresh models. Replaced `--refresh` flag with `--cached` to display local cache. Added comprehensive unit tests covering OpenAI and Perplexity formats, array format, empty/null JSON, escaped quotes, and whitespace handling.
63 lines
2.9 KiB
C
63 lines
2.9 KiB
C
/*
|
|
* 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_insensitive(void** state);
|
|
/* Provider default model and settings tests */
|
|
void test_ai_set_provider_default_model(void** state);
|
|
void test_ai_get_provider_default_model(void** state);
|
|
void test_ai_set_provider_setting(void** state);
|
|
void test_ai_get_provider_setting(void** state);
|
|
/* Model caching tests */
|
|
void test_ai_models_are_fresh_initial(void** state);
|
|
/* Model parsing tests */
|
|
void test_ai_parse_models_openai_format(void** state);
|
|
void test_ai_parse_models_perplexity_format(void** state);
|
|
void test_ai_parse_models_array_format(void** state);
|
|
void test_ai_parse_models_empty_json(void** state);
|
|
void test_ai_parse_models_null_handling(void** state);
|
|
void test_ai_parse_models_escaped_quotes(void** state);
|
|
void test_ai_parse_models_with_whitespace(void** state);
|
|
/* AI autocomplete integration tests */
|
|
void test_ai_start_provider_autocomplete_only_on_exact(void** state);
|
|
void test_ai_models_find_null_session(void** state);
|
|
void test_ai_models_find_null_provider(void** state);
|
|
void test_ai_providers_find_cycling(void** state);
|