Skip to content

Commit 3b08398

Browse files
committed
fix enum boxing tests
1 parent 70f90bf commit 3b08398

2 files changed

Lines changed: 30 additions & 12 deletions

File tree

samples/client/petstore/rust/reqwest/petstore-async/tests/inline_enum_boxing_test.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,22 @@ fn test_inline_enum_not_boxed_in_constructor() {
2121
}
2222

2323
#[test]
24-
fn test_existing_ref_enum_still_works() {
25-
// The Order model has a Status enum, which should still work
26-
// This ensures the fix didn't break existing enum handling
27-
let order = Order::new();
24+
fn test_existing_inline_enum_in_order_model() {
25+
// The Order model has an inline Status enum (placed, approved, shipped)
26+
// This ensures the fix works for enums in other models too
27+
let mut order = Order::new();
2828

29-
// The status field should work normally
30-
assert!(order.status.is_none() || order.status.is_some());
29+
// Set the status to a specific enum value
30+
order.status = Some(petstore_reqwest_async::models::order::Status::Placed);
31+
32+
// Verify we can access and compare the enum
33+
assert_eq!(order.status, Some(petstore_reqwest_async::models::order::Status::Placed));
34+
35+
// Verify it's not boxed - this is a compile-time check
36+
if let Some(status) = order.status {
37+
let _status_ref: petstore_reqwest_async::models::order::Status = status;
38+
assert_eq!(status, petstore_reqwest_async::models::order::Status::Placed);
39+
}
3140
}
3241

3342
#[test]

samples/client/petstore/rust/reqwest/petstore/tests/inline_enum_boxing_test.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,22 @@ fn test_inline_enum_not_boxed_in_constructor() {
2121
}
2222

2323
#[test]
24-
fn test_existing_ref_enum_still_works() {
25-
// The Order model has a Status enum, which should still work
26-
// This ensures the fix didn't break existing enum handling
27-
let order = Order::new();
24+
fn test_existing_inline_enum_in_order_model() {
25+
// The Order model has an inline Status enum (placed, approved, shipped)
26+
// This ensures the fix works for enums in other models too
27+
let mut order = Order::new();
2828

29-
// The status field should work normally
30-
assert!(order.status.is_none() || order.status.is_some());
29+
// Set the status to a specific enum value
30+
order.status = Some(petstore_reqwest::models::order::Status::Placed);
31+
32+
// Verify we can access and compare the enum
33+
assert_eq!(order.status, Some(petstore_reqwest::models::order::Status::Placed));
34+
35+
// Verify it's not boxed - this is a compile-time check
36+
if let Some(status) = order.status {
37+
let _status_ref: petstore_reqwest::models::order::Status = status;
38+
assert_eq!(status, petstore_reqwest::models::order::Status::Placed);
39+
}
3140
}
3241

3342
#[test]

0 commit comments

Comments
 (0)