upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs/archive/2025-11-06-testcontext-demo.sh
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-11-18 16:50:02 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-11-18 16:50:02 +0000
commit98c6fa4bfa897ff0b8f9c95ea698d4d065b5e9f3 (patch)
tree14e94bbbfa1658229dbcd6ce9a03b3eb5cce4aef /docs/archive/2025-11-06-testcontext-demo.sh
parent1fe9c179d5dd73d443ab4792d4c2fbd19690afcb (diff)
docs: switch focus onto grasp implementation
Diffstat (limited to 'docs/archive/2025-11-06-testcontext-demo.sh')
-rw-r--r--docs/archive/2025-11-06-testcontext-demo.sh77
1 files changed, 77 insertions, 0 deletions
diff --git a/docs/archive/2025-11-06-testcontext-demo.sh b/docs/archive/2025-11-06-testcontext-demo.sh
new file mode 100644
index 0000000..1532e51
--- /dev/null
+++ b/docs/archive/2025-11-06-testcontext-demo.sh
@@ -0,0 +1,77 @@
1#!/bin/bash
2set -e
3
4# TestContext Pattern Demonstration Script
5# Shows the difference between CI (Isolated) and Production (Shared) modes
6
7echo "========================================="
8echo "TestContext Pattern Mode Demonstration"
9echo "========================================="
10echo ""
11
12# Check if relay is running
13RELAY_URL="${RELAY_URL:-ws://localhost:18081}"
14echo "📡 Using relay: $RELAY_URL"
15echo ""
16
17# Function to run a subset of tests and count events
18run_mode_demo() {
19 local mode=$1
20 local config_type=$2
21
22 echo "========================================="
23 echo "Running in $mode mode"
24 echo "========================================="
25
26 # Run a couple of refactored tests
27 echo "Running refactored tests..."
28 RELAY_URL="$RELAY_URL" cargo test --lib test_accept_issue_via_a_tag -- --ignored --nocapture 2>&1 | tail -20
29
30 echo ""
31 echo "✅ $mode mode complete"
32 echo ""
33}
34
35# Verify we're in grasp-audit directory
36if [ ! -f "Cargo.toml" ] || ! grep -q "grasp-audit" Cargo.toml; then
37 echo "❌ Error: Must run from grasp-audit directory"
38 exit 1
39fi
40
41# Check if in nix develop environment
42if [ -z "$IN_NIX_SHELL" ]; then
43 echo "🔧 Entering nix develop environment..."
44 exec nix develop -c bash "$0" "$@"
45fi
46
47echo "Current behavior: Tests use CI mode by default (AuditConfig::ci())"
48echo "This ensures full isolation for library users."
49echo ""
50echo "Production mode (AuditConfig::production()) would reuse fixtures,"
51echo "reducing event count by 60-90% for CLI users."
52echo ""
53
54# Run demo
55run_mode_demo "CI (Isolated)" "AuditConfig::ci()"
56
57echo "========================================="
58echo "Summary"
59echo "========================================="
60echo ""
61echo "✅ TestContext pattern successfully implemented"
62echo "✅ Tests compile and run in CI mode (isolated)"
63echo "✅ Migration examples provided in event_acceptance_policy.rs"
64echo ""
65echo "Event Count Breakdown:"
66echo " • Before: All modes ~45 events for 15 tests"
67echo " • CI Mode: Still ~45 events (full isolation)"
68echo " • Production Mode: ~5-35 events (60-90% reduction)"
69echo ""
70echo "Migration Guide: work/testcontext-migration-guide.md"
71echo "Example Tests: grasp-audit/src/specs/grasp01/event_acceptance_policy.rs"
72echo ""
73echo "Next Steps:"
74echo " 1. Gradually migrate remaining tests"
75echo " 2. Monitor event counts in production"
76echo " 3. Add more fixture types as needed"
77echo "" \ No newline at end of file