Skip to content

Commit 18d7273

Browse files
committed
test(config): a v0.10.2 Codex block now upgrades in place to the PreToolUse block
config_toml_codex_accepts_v0102_managed_windows_crlf asserted that re-upserting over the v0.10.2 lifecycle-only block left the file byte-identical. That block is now the previous generation: the upsert accepts it as owned and upgrades it in place. The test now pins that upgrade (one PreToolUse table, BOM, CRLF and the surrounding tables kept) and that a second upsert is byte-identical. Refs DeusData#715 Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 3e5234f commit 18d7273

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎tests/test_config_toml_edit.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,27 +1457,33 @@ TEST(config_toml_codex_accepts_v0102_managed_windows_crlf) {
14571457
ASSERT_EQ(cte_read(path, actual, sizeof(actual)), 0);
14581458
ASSERT_STR_EQ(actual, before);
14591459

1460+
/* The v0.10.2 lifecycle-only block is ours: the upsert upgrades it in place to
1461+
* the current block (which adds PreToolUse Bash) and keeps the BOM, CRLF and
1462+
* the surrounding tables; a second upsert is then byte-identical. */
14601463
ASSERT_EQ(cte_codex_edit_commands_detailed(path, command, command_windows,
14611464
CBM_TOML_CODEX_HOOK_UPSERT, 0, &failure),
14621465
0);
14631466
ASSERT_EQ(cte_read(path, actual, sizeof(actual)), 0);
1464-
ASSERT_STR_EQ(actual, before);
1467+
ASSERT_EQ(strncmp(actual, "\xEF\xBB\xBF", 3U), 0);
14651468
ASSERT_EQ(cte_occurrences(actual, CTE_CODEX_BEGIN), 1);
14661469
ASSERT_EQ(cte_occurrences(actual, "[[hooks.SessionStart]]"), 1);
14671470
ASSERT_EQ(cte_occurrences(actual, "[[hooks.SubagentStart]]"), 1);
1471+
ASSERT_EQ(cte_occurrences(actual, "[[hooks.PreToolUse]]"), 1);
14681472
ASSERT_NOT_NULL(strstr(actual, "[mcp_servers.other]"));
14691473
ASSERT_NOT_NULL(strstr(actual, "keep = true"));
14701474
for (const char *cursor = actual; *cursor; ++cursor) {
14711475
if (*cursor == '\n') {
14721476
ASSERT(cursor > actual && cursor[-1] == '\r');
14731477
}
14741478
}
1479+
char upgraded[CTE_FILE_CAP];
1480+
ASSERT_GT(snprintf(upgraded, sizeof(upgraded), "%s", actual), 0);
14751481

14761482
ASSERT_EQ(cte_codex_edit_commands_detailed(path, command, command_windows,
14771483
CBM_TOML_CODEX_HOOK_UPSERT, 0, &failure),
14781484
0);
14791485
ASSERT_EQ(cte_read(path, actual, sizeof(actual)), 0);
1480-
ASSERT_STR_EQ(actual, before);
1486+
ASSERT_STR_EQ(actual, upgraded);
14811487

14821488
ASSERT_EQ(cte_codex_edit_commands_detailed(path, command, command_windows,
14831489
CBM_TOML_CODEX_HOOK_REMOVE, 0, &failure),

0 commit comments

Comments
 (0)