Files
cproof/tests/unittests/test_database_export.h
jabber.developer2 fa2b21152f
Some checks failed
CI Code / Check spelling (pull_request) Successful in 24s
CI Code / Check coding style (pull_request) Failing after 35s
CI Code / Code Coverage (pull_request) Successful in 7m3s
CI Code / Linux (debian) (pull_request) Successful in 8m32s
CI Code / Linux (ubuntu) (pull_request) Successful in 8m38s
CI Code / Linux (arch) (pull_request) Successful in 8m53s
feat: complete field parity, harden export/import, add tests
Export/Import improvements:
- Replace pagination with direct SQL query (db_sqlite_get_all_chat)
- Wrap import in SQL transaction with rollback on error
- Add fsync before fclose in export for data safety
- Sort merged output by timestamp with secondary key (stanza_id, from_jid)
- Export archive_id and marked_read from SQLite (lossless migration)
- Add progress indication every 500 messages during write/import
- Expand dedup key body prefix from 64 to 256 chars
- Fix g_slist_append O(n²) → g_slist_prepend + g_slist_reverse O(n)

Field parity (to_jid, to_resource, marked_read):
- Add fields to ff_parsed_line_t struct
- Write/parse to:|to_res:|read: metadata tags in flatfile format
- Pass to_resource through _ff_add_message and all callers
- Add marked_read to ProfMessage struct with -1 default (unset)
- Preserve fields across export/import round-trips

Tests (19 new: 11 unit + 8 functional):
- Unit: to_jid_and_marked_read, bracket_in_stanza_id, backslash_in_resource,
  mucpm_type, all_enc_types, crlf_handling, to_jid_special_chars,
  multiple_lines, parsed_line_free_null_safe, no_space_rejected,
  unclosed_bracket
- Functional: export_idempotent_no_duplicates, export_lmc_correction_survives,
  switch_preserves_old_backend_data, export_all_contacts,
  import_double_dedup, verify_after_export,
  switch_backends_independent_messages, export_empty_contact
- Rebalance test groups: move Chat Session from Group 3 to Group 4
  (25/33/30/27 instead of 25/33/36/21)
- Remove hardcoded test counts from group comments

Man page:
- Document /history switch sqlite|flatfile
2026-03-09 12:14:41 +03:00

55 lines
2.3 KiB
C

/* test_database_export.h — unit tests for flatfile write/parse round-trip,
* escape/unescape, and jid_to_dir helpers used by export/import. */
/* write → parse round-trip */
void test_ff_roundtrip_simple_chat(void** state);
void test_ff_roundtrip_with_all_metadata(void** state);
void test_ff_roundtrip_with_resource(void** state);
void test_ff_roundtrip_newline_in_body(void** state);
void test_ff_roundtrip_pipe_in_stanza_id(void** state);
void test_ff_roundtrip_backslash_in_body(void** state);
void test_ff_roundtrip_unicode_body(void** state);
void test_ff_roundtrip_empty_body(void** state);
void test_ff_roundtrip_colonspace_in_resource(void** state);
void test_ff_roundtrip_muc_type(void** state);
void test_ff_roundtrip_omemo_enc(void** state);
void test_ff_roundtrip_replace_id(void** state);
void test_ff_roundtrip_to_jid_and_marked_read(void** state);
/* escape / unescape symmetry */
void test_ff_escape_unescape_message_identity(void** state);
void test_ff_escape_unescape_meta_identity(void** state);
void test_ff_escape_meta_null_returns_null(void** state);
void test_ff_escape_message_null_returns_empty(void** state);
/* jid_to_dir */
void test_ff_jid_to_dir_simple(void** state);
void test_ff_jid_to_dir_with_at(void** state);
void test_ff_jid_to_dir_path_traversal_rejected(void** state);
void test_ff_jid_to_dir_null(void** state);
/* parser edge cases */
void test_ff_parse_line_empty(void** state);
void test_ff_parse_line_comment(void** state);
void test_ff_parse_line_legacy_format(void** state);
void test_ff_parse_line_no_metadata(void** state);
void test_ff_parse_line_invalid_timestamp(void** state);
/* type/enc conversion round-trip */
void test_ff_type_str_roundtrip(void** state);
void test_ff_enc_str_roundtrip(void** state);
/* additional round-trip */
void test_ff_roundtrip_bracket_in_stanza_id(void** state);
void test_ff_roundtrip_backslash_in_resource(void** state);
void test_ff_roundtrip_mucpm_type(void** state);
void test_ff_roundtrip_all_enc_types(void** state);
void test_ff_roundtrip_crlf_handling(void** state);
void test_ff_roundtrip_to_jid_special_chars(void** state);
void test_ff_roundtrip_multiple_lines(void** state);
/* additional parser edge cases */
void test_ff_parsed_line_free_null_safe(void** state);
void test_ff_parse_line_no_space_rejected(void** state);
void test_ff_parse_line_unclosed_bracket(void** state);