Files
drharness/tests/test_load_chat.sh
2026-05-09 12:26:08 -05:00

48 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# test_load_chat.sh - Validates loading and continuing old chats
# Create the file it will read
echo "Initial content" > load_test.txt
# Step 1: Start a new chat
tool_call read_file '{"path":"load_test.txt"}' >> mock_responses1.txt
be_done 'Step 1 done' >> mock_responses1.txt
"${DRHARNESS}" -F load_chat.json -n -m "Start chat step 1" -t read_file -d < "mock_responses1.txt" >/dev/null 2>&1
# Verify step 1 saved correctly
HIST_LEN=$(history_length load_chat.json)
if [ "$HIST_LEN" -lt 4 ]; then
echo "FAIL: load_chat - initial chat didn't save properly"
exit 1
fi
# Verify the file content was read correctly
RESULT=$(dr_result load_chat.json 2)
if [ "$RESULT" != "Initial content" ]; then
echo "FAIL: load_chat - step 1 file content mismatch"
exit 1
fi
# Step 2: Continue the same chat without -n
tool_call read_file '{"path":"load_test.txt"}' >> mock_responses2.txt
be_done 'Step 2 done' >> mock_responses2.txt
"${DRHARNESS}" -F load_chat.json -m "Continue chat step 2" -t read_file -d < "mock_responses2.txt" >/dev/null 2>&1
HIST_LEN_AFTER=$(history_length load_chat.json)
if [ "$HIST_LEN_AFTER" -le "$HIST_LEN" ]; then
echo "FAIL: load_chat - history was not appended"
exit 1
fi
# Verify the old tool result is still there
RESULT2=$(dr_result load_chat.json 2)
if [ "$RESULT2" != "Initial content" ]; then
echo "FAIL: load_chat - history was not preserved"
echo "Expected initial content, got: $RESULT2"
exit 1
fi
echo "PASS: load_chat"