Skip to content

Commit 318f621

Browse files
authored
[integration-tests] simplify some fixture names a bit (#9)
1 parent ef3c410 commit 318f621

4 files changed

Lines changed: 74 additions & 70 deletions

File tree

crates/integration-tests/src/common/fixtures.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ pub mod versioned_health_reduced {
457457

458458
api_versions!([(2, WITH_DETAILED_STATUS), (1, INITIAL)]);
459459

460-
#[dropshot::api_description]
460+
#[dropshot::api_description { module = "api_mod" }]
461461
pub trait VersionedHealthApi {
462462
type Context;
463463

@@ -499,7 +499,7 @@ pub mod versioned_health_skip_middle {
499499

500500
api_versions!([(3, WITH_METRICS), (1, INITIAL)]);
501501

502-
#[dropshot::api_description]
502+
#[dropshot::api_description { module = "api_mod" }]
503503
pub trait VersionedHealthApi {
504504
type Context;
505505

@@ -545,13 +545,13 @@ pub mod versioned_health_skip_middle {
545545

546546
/// Versioned health API with incompatible changes - this breaks backward
547547
/// compatibility by changing the response schema of an existing endpoint.
548-
pub mod versioned_health_incompatible {
548+
pub mod versioned_health_incompat {
549549
use super::*;
550550
use dropshot_api_manager_types::api_versions;
551551

552552
api_versions!([(3, WITH_METRICS), (2, WITH_DETAILED_STATUS), (1, INITIAL)]);
553553

554-
#[dropshot::api_description]
554+
#[dropshot::api_description { module = "api_mod" }]
555555
pub trait VersionedHealthApi {
556556
type Context;
557557

crates/integration-tests/src/common/mod.rs

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,7 @@ pub fn rel_path_forward_slashes(path: &str) -> String {
387387
path.to_string()
388388
}
389389

390-
/// Create a versioned health API test configuration.
391-
pub fn versioned_health_test_api() -> ManagedApiConfig {
390+
pub fn versioned_health_api() -> ManagedApiConfig {
392391
ManagedApiConfig {
393392
ident: "versioned-health",
394393
versions: Versions::Versioned {
@@ -404,8 +403,7 @@ pub fn versioned_health_test_api() -> ManagedApiConfig {
404403
}
405404
}
406405

407-
/// Create a versioned user API test configuration.
408-
pub fn versioned_user_test_api() -> ManagedApiConfig {
406+
pub fn versioned_user_api() -> ManagedApiConfig {
409407
ManagedApiConfig {
410408
ident: "versioned-user",
411409
versions: Versions::Versioned {
@@ -421,7 +419,7 @@ pub fn versioned_user_test_api() -> ManagedApiConfig {
421419
}
422420
}
423421

424-
pub fn health_test_api() -> ManagedApiConfig {
422+
pub fn lockstep_health_api() -> ManagedApiConfig {
425423
ManagedApiConfig {
426424
ident: "health",
427425
versions: Versions::Lockstep { version: Version::new(1, 0, 0) },
@@ -435,7 +433,7 @@ pub fn health_test_api() -> ManagedApiConfig {
435433
}
436434
}
437435

438-
pub fn counter_test_api() -> ManagedApiConfig {
436+
pub fn lockstep_counter_api() -> ManagedApiConfig {
439437
ManagedApiConfig {
440438
ident: "counter",
441439
versions: Versions::Lockstep { version: Version::new(1, 0, 0) },
@@ -449,7 +447,7 @@ pub fn counter_test_api() -> ManagedApiConfig {
449447
}
450448
}
451449

452-
pub fn user_test_api() -> ManagedApiConfig {
450+
pub fn lockstep_user_api() -> ManagedApiConfig {
453451
ManagedApiConfig {
454452
ident: "user",
455453
versions: Versions::Lockstep { version: Version::new(1, 0, 0) },
@@ -464,64 +462,67 @@ pub fn user_test_api() -> ManagedApiConfig {
464462
}
465463

466464
/// Create a health API for basic testing.
467-
pub fn create_health_test_apis() -> Result<ManagedApis> {
468-
ManagedApis::new(vec![health_test_api()])
465+
pub fn lockstep_health_apis() -> Result<ManagedApis> {
466+
ManagedApis::new(vec![lockstep_health_api()])
469467
.context("failed to create ManagedApis")
470468
}
471469

472470
/// Create a counter test API configuration.
473-
pub fn create_counter_test_apis() -> Result<ManagedApis> {
474-
ManagedApis::new(vec![counter_test_api()])
471+
pub fn lockstep_counter_apis() -> Result<ManagedApis> {
472+
ManagedApis::new(vec![lockstep_counter_api()])
475473
.context("failed to create ManagedApis")
476474
}
477475

478476
/// Create a user test API configuration.
479-
pub fn create_user_test_apis() -> Result<ManagedApis> {
480-
ManagedApis::new(vec![user_test_api()])
477+
pub fn lockstep_user_apis() -> Result<ManagedApis> {
478+
ManagedApis::new(vec![lockstep_user_api()])
481479
.context("failed to create ManagedApis")
482480
}
483481

484482
/// Helper to create multiple test APIs.
485-
pub fn create_multi_test_apis() -> Result<ManagedApis> {
486-
let configs = vec![health_test_api(), counter_test_api(), user_test_api()];
483+
pub fn lockstep_multi_apis() -> Result<ManagedApis> {
484+
let configs = vec![
485+
lockstep_health_api(),
486+
lockstep_counter_api(),
487+
lockstep_user_api(),
488+
];
487489
ManagedApis::new(configs).context("failed to create ManagedApis")
488490
}
489491

490492
/// Create a versioned health API for testing.
491-
pub fn create_versioned_health_test_apis() -> Result<ManagedApis> {
492-
ManagedApis::new(vec![versioned_health_test_api()])
493+
pub fn versioned_health_apis() -> Result<ManagedApis> {
494+
ManagedApis::new(vec![versioned_health_api()])
493495
.context("failed to create versioned health ManagedApis")
494496
}
495497

496498
/// Create a versioned user API for testing.
497-
pub fn create_versioned_user_test_apis() -> Result<ManagedApis> {
498-
ManagedApis::new(vec![versioned_user_test_api()])
499+
pub fn versioned_user_apis() -> Result<ManagedApis> {
500+
ManagedApis::new(vec![versioned_user_api()])
499501
.context("failed to create versioned user ManagedApis")
500502
}
501503

502504
/// Helper to create multiple versioned test APIs.
503-
pub fn create_multi_versioned_test_apis() -> Result<ManagedApis> {
504-
let configs = vec![versioned_health_test_api(), versioned_user_test_api()];
505+
pub fn multi_versioned_apis() -> Result<ManagedApis> {
506+
let configs = vec![versioned_health_api(), versioned_user_api()];
505507
ManagedApis::new(configs).context("failed to create versioned ManagedApis")
506508
}
507509

508510
/// Helper to create mixed lockstep and versioned test APIs.
509511
pub fn create_mixed_test_apis() -> Result<ManagedApis> {
510512
let configs = vec![
511-
health_test_api(),
512-
counter_test_api(),
513-
versioned_health_test_api(),
514-
versioned_user_test_api(),
513+
lockstep_health_api(),
514+
lockstep_counter_api(),
515+
versioned_health_api(),
516+
versioned_user_api(),
515517
];
516518
ManagedApis::new(configs).context("failed to create mixed ManagedApis")
517519
}
518520

519521
/// Create versioned health API with a trivial change (title/metadata updated).
520-
pub fn create_versioned_health_test_apis_with_trivial_change()
521-
-> Result<ManagedApis> {
522+
pub fn versioned_health_trivial_change_apis() -> Result<ManagedApis> {
522523
// Create a modified API config that would produce different OpenAPI
523524
// documents.
524-
let mut config = versioned_health_test_api();
525+
let mut config = versioned_health_api();
525526

526527
// Modify the title to create a different document signature.
527528
config.title = "Modified Versioned Health API";
@@ -534,30 +535,31 @@ pub fn create_versioned_health_test_apis_with_trivial_change()
534535

535536
/// Create versioned health API with reduced versions (simulating version
536537
/// removal).
537-
pub fn create_versioned_health_test_apis_reduced_versions()
538-
-> Result<ManagedApis> {
538+
pub fn versioned_health_reduced_apis() -> Result<ManagedApis> {
539539
// Create a configuration similar to versioned health but with fewer
540540
// versions. We'll create a new fixture for this.
541541
let config = ManagedApiConfig {
542542
ident: "versioned-health",
543543
versions: Versions::Versioned {
544544
// Use a subset of versions (only 1.0.0 and 2.0.0, not 3.0.0).
545-
supported_versions: fixtures::versioned_health_reduced::supported_versions(),
545+
supported_versions:
546+
fixtures::versioned_health_reduced::supported_versions(),
546547
},
547548
title: "Versioned Health API",
548549
metadata: ManagedApiMetadata {
549550
description: Some("A versioned health API with reduced versions"),
550551
..Default::default()
551552
},
552-
api_description: fixtures::versioned_health_reduced::versioned_health_api_mod::stub_api_description,
553+
api_description:
554+
fixtures::versioned_health_reduced::api_mod::stub_api_description,
553555
extra_validation: None,
554556
};
555557

556558
ManagedApis::new(vec![config])
557559
.context("failed to create reduced versioned health ManagedApis")
558560
}
559561

560-
pub fn create_versioned_health_test_apis_skip_middle() -> Result<ManagedApis> {
562+
pub fn versioned_health_skip_middle_apis() -> Result<ManagedApis> {
561563
// Create a configuration similar to versioned health but skipping the
562564
// middle version. This has versions 3.0.0 and 1.0.0, simulating retirement
563565
// of version 2.0.0.
@@ -572,7 +574,7 @@ pub fn create_versioned_health_test_apis_skip_middle() -> Result<ManagedApis> {
572574
description: Some("A versioned health API that skips middle version"),
573575
..Default::default()
574576
},
575-
api_description: fixtures::versioned_health_skip_middle::versioned_health_api_mod::stub_api_description,
577+
api_description: fixtures::versioned_health_skip_middle::api_mod::stub_api_description,
576578
extra_validation: None,
577579
};
578580

@@ -582,20 +584,24 @@ pub fn create_versioned_health_test_apis_skip_middle() -> Result<ManagedApis> {
582584

583585
/// Create a versioned health API with incompatible changes that break backward
584586
/// compatibility.
585-
pub fn create_versioned_health_test_apis_incompatible() -> Result<ManagedApis> {
587+
pub fn versioned_health_incompat_apis() -> Result<ManagedApis> {
586588
// Create a configuration similar to versioned health but with incompatible
587589
// changes that break backward compatibility.
588590
let config = ManagedApiConfig {
589591
ident: "versioned-health",
590592
versions: Versions::Versioned {
591-
supported_versions: fixtures::versioned_health_incompatible::supported_versions(),
593+
supported_versions:
594+
fixtures::versioned_health_incompat::supported_versions(),
592595
},
593596
title: "Versioned Health API",
594597
metadata: ManagedApiMetadata {
595-
description: Some("A versioned health API with incompatible changes"),
598+
description: Some(
599+
"A versioned health API with incompatible changes",
600+
),
596601
..Default::default()
597602
},
598-
api_description: fixtures::versioned_health_incompatible::versioned_health_api_mod::stub_api_description,
603+
api_description:
604+
fixtures::versioned_health_incompat::api_mod::stub_api_description,
599605
extra_validation: None,
600606
};
601607

crates/integration-tests/tests/integration/lockstep.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use openapiv3::OpenAPI;
1818
#[test]
1919
fn test_lockstep_generate_basic() -> Result<()> {
2020
let env = TestEnvironment::new()?;
21-
let apis = create_health_test_apis()?;
21+
let apis = lockstep_health_apis()?;
2222

2323
// Initially, no documents should exist.
2424
assert!(!env.lockstep_document_exists("health"));
@@ -49,7 +49,7 @@ fn test_lockstep_generate_basic() -> Result<()> {
4949
#[test]
5050
fn test_lockstep_always_up_to_date() -> Result<()> {
5151
let env = TestEnvironment::new()?;
52-
let apis = create_multi_test_apis()?;
52+
let apis = lockstep_multi_apis()?;
5353

5454
// Generate all documents.
5555
env.generate_documents(&apis)?;
@@ -65,7 +65,7 @@ fn test_lockstep_always_up_to_date() -> Result<()> {
6565
#[test]
6666
fn test_lockstep_multiple_apis() -> Result<()> {
6767
let env = TestEnvironment::new()?;
68-
let apis = create_multi_test_apis()?;
68+
let apis = lockstep_multi_apis()?;
6969

7070
// Generate all documents.
7171
env.generate_documents(&apis)?;

0 commit comments

Comments
 (0)