Skip to content

Commit 57ea759

Browse files
calebbourgclaude
andcommitted
feat(sse-test-client): add ConnectionTest and ForceLogoutTest scenarios
- Add ConnectionTest scenario choice to CLI - Add ForceLogoutTest scenario choice to CLI - Make test environment setup conditional (skip for ConnectionTest) - Update All scenario to include ConnectionTest - Improve scenario descriptions with requirements ConnectionTest can run without admin permissions since it doesn't require creating coaching relationships or sessions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 9f3f260 commit 57ea759

File tree

1 file changed

+85
-41
lines changed

1 file changed

+85
-41
lines changed

sse-test-client/src/main.rs

Lines changed: 85 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,17 @@ struct Cli {
4040

4141
#[derive(clap::ValueEnum, Clone)]
4242
enum ScenarioChoice {
43+
/// Test basic SSE connection without creating any data
44+
ConnectionTest,
45+
/// Test force logout event (no coaching data needed)
46+
ForceLogoutTest,
47+
/// Test action create event (requires coaching session)
4348
ActionCreate,
49+
/// Test action update event (requires coaching session)
4450
ActionUpdate,
51+
/// Test action delete event (requires coaching session)
4552
ActionDelete,
46-
ForceLogout,
53+
/// Run all tests including those requiring coaching data
4754
All,
4855
}
4956

@@ -80,31 +87,43 @@ async fn main() -> Result<()> {
8087
user2.user_id
8188
);
8289

83-
// Set up test environment
84-
println!(
85-
"\n{} Creating test coaching relationship and session...",
86-
"→".blue()
87-
);
90+
// Set up test environment only for scenarios that need coaching data
8891
let api_client = ApiClient::new(client.clone(), cli.base_url.clone());
89-
let test_env = api_client
90-
.setup_test_environment(
91-
&user1.session_cookie,
92-
&user2.session_cookie,
93-
&user1.user_id,
94-
&user2.user_id,
95-
)
96-
.await?;
92+
let test_env = match cli.scenario {
93+
ScenarioChoice::ConnectionTest => {
94+
println!(
95+
"\n{} Skipping test environment setup (not needed for connection test)",
96+
"→".blue()
97+
);
98+
None
99+
}
100+
_ => {
101+
println!(
102+
"\n{} Creating test coaching relationship and session...",
103+
"→".blue()
104+
);
105+
let env = api_client
106+
.setup_test_environment(
107+
&user1.session_cookie,
108+
&user2.session_cookie,
109+
&user1.user_id,
110+
&user2.user_id,
111+
)
112+
.await?;
97113

98-
println!(
99-
"{} Coaching relationship created (ID: {})",
100-
"✓".green(),
101-
test_env.relationship_id
102-
);
103-
println!(
104-
"{} Coaching session created (ID: {})",
105-
"✓".green(),
106-
test_env.session_id
107-
);
114+
println!(
115+
"{} Coaching relationship created (ID: {})",
116+
"✓".green(),
117+
env.relationship_id
118+
);
119+
println!(
120+
"{} Coaching session created (ID: {})",
121+
"✓".green(),
122+
env.session_id
123+
);
124+
Some(env)
125+
}
126+
};
108127

109128
// Establish SSE connections
110129
println!("\n{} Establishing SSE connections...", "→".blue());
@@ -131,12 +150,38 @@ async fn main() -> Result<()> {
131150
let mut results = Vec::new();
132151

133152
match cli.scenario {
153+
ScenarioChoice::ConnectionTest => {
154+
results.push(
155+
scenarios::test_connection(
156+
&user1,
157+
&user2,
158+
&mut sse1,
159+
&mut sse2,
160+
)
161+
.await?,
162+
);
163+
}
164+
ScenarioChoice::ForceLogoutTest => {
165+
let env = test_env.as_ref().expect("Test environment required for ForceLogoutTest");
166+
results.push(
167+
scenarios::test_force_logout(
168+
&user1,
169+
&user2,
170+
env,
171+
&api_client,
172+
&mut sse1,
173+
&mut sse2,
174+
)
175+
.await?,
176+
);
177+
}
134178
ScenarioChoice::ActionCreate => {
179+
let env = test_env.as_ref().expect("Test environment required for ActionCreate");
135180
results.push(
136181
scenarios::test_action_create(
137182
&user1,
138183
&user2,
139-
&test_env,
184+
env,
140185
&api_client,
141186
&mut sse1,
142187
&mut sse2,
@@ -145,11 +190,12 @@ async fn main() -> Result<()> {
145190
);
146191
}
147192
ScenarioChoice::ActionUpdate => {
193+
let env = test_env.as_ref().expect("Test environment required for ActionUpdate");
148194
results.push(
149195
scenarios::test_action_update(
150196
&user1,
151197
&user2,
152-
&test_env,
198+
env,
153199
&api_client,
154200
&mut sse1,
155201
&mut sse2,
@@ -158,70 +204,68 @@ async fn main() -> Result<()> {
158204
);
159205
}
160206
ScenarioChoice::ActionDelete => {
207+
let env = test_env.as_ref().expect("Test environment required for ActionDelete");
161208
results.push(
162209
scenarios::test_action_delete(
163210
&user1,
164211
&user2,
165-
&test_env,
212+
env,
166213
&api_client,
167214
&mut sse1,
168215
&mut sse2,
169216
)
170217
.await?,
171218
);
172219
}
173-
ScenarioChoice::ForceLogout => {
220+
ScenarioChoice::All => {
174221
results.push(
175-
scenarios::test_force_logout(
222+
scenarios::test_connection(
176223
&user1,
177224
&user2,
178-
&test_env,
179-
&api_client,
180225
&mut sse1,
181226
&mut sse2,
182227
)
183228
.await?,
184229
);
185-
}
186-
ScenarioChoice::All => {
230+
let env = test_env.as_ref().expect("Test environment required for All scenarios");
187231
results.push(
188-
scenarios::test_action_create(
232+
scenarios::test_force_logout(
189233
&user1,
190234
&user2,
191-
&test_env,
235+
env,
192236
&api_client,
193237
&mut sse1,
194238
&mut sse2,
195239
)
196240
.await?,
197241
);
198242
results.push(
199-
scenarios::test_action_update(
243+
scenarios::test_action_create(
200244
&user1,
201245
&user2,
202-
&test_env,
246+
env,
203247
&api_client,
204248
&mut sse1,
205249
&mut sse2,
206250
)
207251
.await?,
208252
);
209253
results.push(
210-
scenarios::test_action_delete(
254+
scenarios::test_action_update(
211255
&user1,
212256
&user2,
213-
&test_env,
257+
env,
214258
&api_client,
215259
&mut sse1,
216260
&mut sse2,
217261
)
218262
.await?,
219263
);
220264
results.push(
221-
scenarios::test_force_logout(
265+
scenarios::test_action_delete(
222266
&user1,
223267
&user2,
224-
&test_env,
268+
env,
225269
&api_client,
226270
&mut sse1,
227271
&mut sse2,

0 commit comments

Comments
 (0)