docs: update README, dev scripts, and documentation
Update project documentation and development scripts. - Update README test counts (953/957 passing, 8 skipped) - Simplify dev script: remove test DB seeding, add name history creation, clean up stale test databases on startup, remove -p 1 test flag - Update obsidian documentation for new features: - Name history system docs - Referral discount system docs - Database migration docs (CHAR(12) short IDs) Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
+31
-27
@@ -70,33 +70,18 @@ log_step "Allowing PostgreSQL to fully initialize..."
|
||||
sleep 5
|
||||
|
||||
# --- 3b. Create Test Database ---
|
||||
log_step "Setting up test database (crussell_test)..."
|
||||
docker exec postgres psql -U myuser -d mydb -c "CREATE DATABASE crussell_test;" 2>&1 || log_info "Test database may already exist"
|
||||
sleep 2
|
||||
|
||||
# --- 3c. Seed Test Database Schema ---
|
||||
log_step "Seeding test database schema..."
|
||||
docker exec -i postgres psql -U myuser -d crussell_test < init-scripts/init-script.sql 2>&1 | head -5 || true
|
||||
log_success "Test database schema seeded"
|
||||
|
||||
# --- 3d. Verify test database is ready ---
|
||||
log_step "Verifying test database readiness..."
|
||||
MAX_ATTEMPTS=10
|
||||
ATTEMPT=0
|
||||
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
|
||||
if docker exec postgres psql -U myuser -d crussell_test -c "SELECT 1;" > /dev/null 2>&1; then
|
||||
log_success "Test database ready"
|
||||
break
|
||||
fi
|
||||
ATTEMPT=$((ATTEMPT+1))
|
||||
sleep 1
|
||||
log_step "Cleaning up stale test databases..."
|
||||
docker exec postgres psql -U myuser -d mydb -t -c "
|
||||
SELECT datname FROM pg_database WHERE datname LIKE 'crussell_test%';
|
||||
" 2>&1 | grep crussell_test | while read -r dbname; do
|
||||
docker exec postgres psql -U myuser -d mydb -c "
|
||||
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '$dbname' AND pid != pg_backend_pid();
|
||||
DROP DATABASE IF EXISTS \"$dbname\";
|
||||
" 2>&1
|
||||
done
|
||||
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
|
||||
log_error "Test database failed to initialize after $MAX_ATTEMPTS attempts"
|
||||
exit 1
|
||||
fi
|
||||
log_success "Test databases cleaned"
|
||||
|
||||
# --- 3e. Rustfs (wipe data for fresh start) ---
|
||||
# --- 3c. Rustfs (wipe data for fresh start) ---
|
||||
log_step "Wiping Rustfs (S3 storage)..."
|
||||
docker compose stop rustfs > /dev/null 2>&1 || true
|
||||
docker compose rm -f rustfs > /dev/null 2>&1 || true
|
||||
@@ -1426,7 +1411,26 @@ fi
|
||||
|
||||
echo "${C_GREEN}✅ Created $edit_req_count Edit Requests${C_RESET}"
|
||||
|
||||
|
||||
# ===========================================================================
|
||||
# 7c. NAME HISTORY (for testing "formerly" display)
|
||||
# ===========================================================================
|
||||
echo -e "\n${C_BLUE}📝 Creating name history entry for test user...${C_RESET}"
|
||||
USER_TOKEN=$(login "user@example.com" "password")
|
||||
if [[ -n "$USER_TOKEN" ]]; then
|
||||
name_resp=$(curl -s -w "\n%{http_code}" -X PUT \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H "Authorization: Bearer $USER_TOKEN" \
|
||||
-d '{"firstName":"Regular","lastName":"Joe","phone":"+447000000001"}' \
|
||||
"$BASE_URL/user/profile")
|
||||
name_code=$(echo "$name_resp" | tail -n1)
|
||||
if [[ "$name_code" =~ ^2 ]]; then
|
||||
echo "${C_GREEN}✅ Name history entry created (Regular User → Joe shows as 'formerly')${C_RESET}"
|
||||
else
|
||||
echo "${C_YELLOW}⚠️ Failed to update user name (HTTP $name_code)${C_RESET}"
|
||||
fi
|
||||
else
|
||||
echo "${C_YELLOW}⚠️ Could not log in as test user for name change${C_RESET}"
|
||||
fi
|
||||
|
||||
# ===========================================================================
|
||||
# SUMMARY
|
||||
@@ -1471,7 +1475,7 @@ cd /home/popertots/Crussell/backend
|
||||
export POSTGRES_USER POSTGRES_PASSWORD POSTGRES_HOST POSTGRES_DB GO_TESTING=1
|
||||
TEST_OUTPUT_FILE=$(mktemp)
|
||||
START_TIME=$(date +%s)
|
||||
go test -tags "test,dev" -v -p 1 -count=1 ./... 2>&1 | tee "$TEST_OUTPUT_FILE" || true
|
||||
go test -tags "test,dev" -v -count=1 ./... 2>&1 | tee "$TEST_OUTPUT_FILE" || true
|
||||
END_TIME=$(date +%s)
|
||||
DURATION=$((END_TIME - START_TIME))
|
||||
MINUTES=$((DURATION / 60))
|
||||
|
||||
Reference in New Issue
Block a user