Skip to content

Commit dcccc2a

Browse files
committed
refactor: move sse-test-client into testing-tools crate
Reorganize sse-test-client into a testing-tools crate to support future testing utilities. This provides a unified location for all testing tools while maintaining the existing sse-test-client binary functionality. Changes: - Create testing-tools crate with library structure - Move sse-test-client source to testing-tools/src/ - Relocate main.rs to testing-tools/src/bin/sse-test-client.rs - Add lib.rs to export shared modules - Update workspace Cargo.toml to reference testing-tools instead of sse-test-client - Update README with new crate structure and usage commands - Preserve binary name and functionality (cargo run -p testing-tools --bin sse-test-client) The binary remains fully functional and all documentation has been updated to reflect the new package structure.
1 parent 54303f0 commit dcccc2a

File tree

11 files changed

+65
-54
lines changed

11 files changed

+65
-54
lines changed

Cargo.lock

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ edition = "2021"
66
default-run = "refactor_platform_rs"
77

88
[workspace]
9-
members = [".", "entity_api", "entity", "migration", "service", "web", "domain", "sse", "sse-test-client"]
10-
# Exclude sse-test-client from default builds - it's a development/testing tool only
9+
members = [".", "entity_api", "entity", "migration", "service", "web", "domain", "sse", "testing-tools"]
10+
# Exclude testing-tools from default builds - it's a development/testing tool only
1111
# and should not be built or deployed in production environments
1212
default-members = [".", "entity_api", "entity", "migration", "service", "web", "domain", "sse"]
1313

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[package]
2-
name = "sse-test-client"
2+
name = "testing-tools"
33
version = "0.1.0"
44
edition = "2021"
55

66
[[bin]]
77
name = "sse-test-client"
8-
path = "src/main.rs"
8+
path = "src/bin/sse-test-client.rs"
99

1010
[dependencies]
1111
# HTTP client
Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
# SSE Test Client
1+
# Testing Tools
2+
3+
A collection of testing utilities and tools for the Refactor Platform.
4+
5+
## SSE Test Client
26

37
A standalone Rust binary for testing Server-Sent Events (SSE) functionality without requiring a frontend client. The tool authenticates as two users, establishes SSE connections, triggers events via API calls, and validates that events are received correctly.
48

5-
## Overview
9+
### Overview
610

711
This tool validates the SSE infrastructure by:
812
1. Authenticating two users (typically a coach and coachee)
@@ -11,48 +15,48 @@ This tool validates the SSE infrastructure by:
1115
4. Triggering events (create/update/delete actions, force logout)
1216
5. Verifying that the correct SSE events are received by the appropriate users
1317

14-
## Prerequisites
18+
### Prerequisites
1519

1620
- Backend server running (default: `http://localhost:4000`)
1721
- Two valid user accounts with credentials (seeded users recommended)
1822
- **For action tests**: An existing coaching relationship between the users (will be created if it doesn't exist)
1923
- **For connection test**: No special permissions or relationships required
2024

21-
## Usage
25+
### Usage
2226

2327
### Run Individual Test Scenarios
2428

2529
```bash
2630
# Test basic SSE connection (no admin permissions required)
27-
cargo run -p sse-test-client -- \
31+
cargo run -p testing-tools --bin sse-test-client -- \
2832
--base-url http://localhost:4000 \
2933
--user1 "james.hodapp@gmail.com:password" \
3034
--user2 "calebbourg2@gmail.com:password" \
3135
--scenario connection-test
3236

3337
# Test action creation (requires admin permissions)
34-
cargo run -p sse-test-client -- \
38+
cargo run -p testing-tools --bin sse-test-client -- \
3539
--base-url http://localhost:4000 \
3640
--user1 "james.hodapp@gmail.com:password" \
3741
--user2 "calebbourg2@gmail.com:password" \
3842
--scenario action-create
3943

4044
# Test action update (requires admin permissions)
41-
cargo run -p sse-test-client -- \
45+
cargo run -p testing-tools --bin sse-test-client -- \
4246
--base-url http://localhost:4000 \
4347
--user1 "james.hodapp@gmail.com:password" \
4448
--user2 "calebbourg2@gmail.com:password" \
4549
--scenario action-update
4650

4751
# Test action delete (requires admin permissions)
48-
cargo run -p sse-test-client -- \
52+
cargo run -p testing-tools --bin sse-test-client -- \
4953
--base-url http://localhost:4000 \
5054
--user1 "james.hodapp@gmail.com:password" \
5155
--user2 "calebbourg2@gmail.com:password" \
5256
--scenario action-delete
5357

5458
# Test force logout (requires admin permissions - NOT YET IMPLEMENTED)
55-
cargo run -p sse-test-client -- \
59+
cargo run -p testing-tools --bin sse-test-client -- \
5660
--base-url http://localhost:4000 \
5761
--user1 "james.hodapp@gmail.com:password" \
5862
--user2 "calebbourg2@gmail.com:password" \
@@ -62,7 +66,7 @@ cargo run -p sse-test-client -- \
6266
### Run All Tests
6367

6468
```bash
65-
cargo run -p sse-test-client -- \
69+
cargo run -p testing-tools --bin sse-test-client -- \
6670
--base-url http://localhost:4000 \
6771
--user1 "james.hodapp@gmail.com:password" \
6872
--user2 "calebbourg2@gmail.com:password" \
@@ -72,15 +76,15 @@ cargo run -p sse-test-client -- \
7276
### Enable Verbose Logging
7377

7478
```bash
75-
cargo run -p sse-test-client -- \
79+
cargo run -p testing-tools --bin sse-test-client -- \
7680
--base-url http://localhost:4000 \
7781
--user1 "james.hodapp@gmail.com:password" \
7882
--user2 "calebbourg2@gmail.com:password" \
7983
--scenario all \
8084
--verbose
8185
```
8286

83-
## Available Scenarios
87+
### Available Scenarios
8488

8589
- `connection-test` - Tests basic SSE connectivity without creating any data
8690
- `action-create` - Tests SSE events for action creation (uses existing coaching relationship or creates one)
@@ -89,7 +93,7 @@ cargo run -p sse-test-client -- \
8993
- `force-logout-test` - Tests SSE events for force logout (NOT YET IMPLEMENTED)
9094
- `all` - Runs all test scenarios sequentially
9195

92-
## Command-Line Arguments
96+
### Command-Line Arguments
9397

9498
| Argument | Required | Description |
9599
|----------|----------|-------------|
@@ -99,7 +103,7 @@ cargo run -p sse-test-client -- \
99103
| `--scenario` | Yes | Test scenario to run (see Available Scenarios) |
100104
| `--verbose` or `-v` | No | Enable verbose output with debug logging |
101105

102-
## How It Works
106+
### How It Works
103107

104108
### Setup Phase
105109
1. Authenticates both users and obtains session cookies
@@ -118,7 +122,7 @@ For each scenario:
118122
- Shows pass/fail status with durations
119123
- Exits with code 0 if all tests pass, 1 if any fail
120124

121-
## Example Output
125+
### Example Output
122126

123127
### Connection Test (No Admin Required)
124128
```
@@ -194,11 +198,12 @@ Results: 1 passed, 0 failed
194198
All tests passed! ✓
195199
```
196200

197-
## Module Structure
201+
### Module Structure
198202

199-
- `main.rs` - CLI entry point and scenario orchestration
200-
- `auth.rs` - User authentication and session management
201-
- `sse_client.rs` - SSE connection handling and event listening
202-
- `api_client.rs` - API calls to create test data and trigger events
203-
- `scenarios.rs` - Test scenario implementations
204-
- `output.rs` - Color-coded console output formatting
203+
- `src/bin/sse-test-client.rs` - CLI entry point and scenario orchestration
204+
- `src/auth.rs` - User authentication and session management
205+
- `src/sse_client.rs` - SSE connection handling and event listening
206+
- `src/api_client.rs` - API calls to create test data and trigger events
207+
- `src/scenarios.rs` - Test scenario implementations
208+
- `src/output.rs` - Color-coded console output formatting
209+
- `src/lib.rs` - Library exports for testing-tools crate
Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@ use anyhow::Result;
22
use clap::Parser;
33
use colored::*;
44

5-
mod api_client;
6-
mod auth;
7-
mod output;
8-
mod scenarios;
9-
mod sse_client;
10-
11-
use api_client::ApiClient;
12-
use auth::{login, UserCredentials};
13-
use output::print_test_summary;
14-
use sse_client::Connection;
5+
use testing_tools::api_client::ApiClient;
6+
use testing_tools::auth::{login, UserCredentials};
7+
use testing_tools::output::print_test_summary;
8+
use testing_tools::scenarios;
9+
use testing_tools::sse_client::Connection;
1510

1611
#[derive(Parser)]
1712
#[command(name = "sse-test-client")]

testing-tools/src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Testing Tools Library
2+
//
3+
// This crate provides various testing utilities and tools for the Refactor Platform.
4+
// Currently includes:
5+
// - sse-test-client: SSE integration testing tool
6+
7+
pub mod api_client;
8+
pub mod auth;
9+
pub mod output;
10+
pub mod scenarios;
11+
pub mod sse_client;

0 commit comments

Comments
 (0)