02975ddfd4
- Added dr_config_base_url and dr_config_model helper functions to run_test.sh - Updated test_harness_config.sh to use be_done() and helper functions instead of inline JSON
62 lines
1.8 KiB
Bash
Executable File
62 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# test_harness_config.sh - Tests for HarnessConfig with base_url and model fields
|
|
|
|
# Test 1: Verify config is saved with base_url and model in new conversations
|
|
echo "$(be_done "Response")" | "${DRHARNESS}" \
|
|
-F "${TEST_TEMP_DIR}/chat.json" \
|
|
-n \
|
|
-d \
|
|
-m "test" 2>/dev/null
|
|
|
|
# Verify config contains base_url and model
|
|
BASE_URL=$(dr_config_base_url "${TEST_TEMP_DIR}/chat.json")
|
|
MODEL=$(dr_config_model "${TEST_TEMP_DIR}/chat.json")
|
|
|
|
if [ -z "$BASE_URL" ] || [ "$BASE_URL" = "null" ]; then
|
|
echo "FAIL: Expected config.base_url to be set"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z "$MODEL" ] || [ "$MODEL" = "null" ]; then
|
|
echo "FAIL: Expected config.model to be set"
|
|
exit 1
|
|
fi
|
|
|
|
# Test 2: Verify -M flag sets model in config
|
|
echo "$(be_done "Response")" | "${DRHARNESS}" \
|
|
-F "${TEST_TEMP_DIR}/chat2.json" \
|
|
-n \
|
|
-d \
|
|
-M "custom-model" \
|
|
-m "test" 2>/dev/null
|
|
|
|
MODEL2=$(dr_config_model "${TEST_TEMP_DIR}/chat2.json")
|
|
if [ "$MODEL2" != "custom-model" ]; then
|
|
echo "FAIL: Expected config.model to be 'custom-model', got '${MODEL2}'"
|
|
exit 1
|
|
fi
|
|
|
|
# Test 3: Verify backward compatibility - loading file without base_url and model
|
|
create_state "${TEST_TEMP_DIR}/old_format.json" user "hello"
|
|
|
|
echo "$(be_done "Response")" | "${DRHARNESS}" \
|
|
-F "${TEST_TEMP_DIR}/old_format.json" \
|
|
-d \
|
|
-m "test" 2>/dev/null
|
|
|
|
# Verify the saved file now has base_url and model with defaults
|
|
SAVED_BASE_URL=$(dr_config_base_url "${TEST_TEMP_DIR}/old_format.json")
|
|
SAVED_MODEL=$(dr_config_model "${TEST_TEMP_DIR}/old_format.json")
|
|
|
|
if [ -z "$SAVED_BASE_URL" ] || [ "$SAVED_BASE_URL" = "null" ]; then
|
|
echo "FAIL: Expected saved config.base_url to be set"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z "$SAVED_MODEL" ] || [ "$SAVED_MODEL" = "null" ]; then
|
|
echo "FAIL: Expected saved config.model to be set"
|
|
exit 1
|
|
fi
|
|
|
|
echo "All harness config tests passed"
|