@@ -43,7 +43,10 @@ impl TestEnvironment {
4343 let documents_dir = workspace_root. child ( "documents" ) ;
4444
4545 // Initialize git repository in workspace root.
46- Self :: run_git_command ( & workspace_root, & [ "init" ] ) ?;
46+ Self :: run_git_command (
47+ & workspace_root,
48+ & [ "init" , "--initial-branch" , "main" ] ,
49+ ) ?;
4750 Self :: run_git_command (
4851 & workspace_root,
4952 & [ "config" , "user.name" , "Test User" ] ,
@@ -70,7 +73,11 @@ impl TestEnvironment {
7073 "test-openapi-manager" ,
7174 workspace_root. as_path ( ) ,
7275 "documents" ,
73- ) ?;
76+ ) ?
77+ // Use "main" rather than the default "origin/main" since we're not
78+ // pushing to an upstream. A commit to main automatically marks the
79+ // document blessed.
80+ . with_default_git_branch ( "main" ) ;
7481
7582 Ok ( Self { temp_dir, workspace_root, documents_dir, environment } )
7683 }
@@ -110,6 +117,15 @@ impl TestEnvironment {
110117 . with_context ( || format ! ( "failed to read file: {}" , path) )
111118 }
112119
120+ pub fn read_link (
121+ & self ,
122+ relative_path : impl AsRef < Utf8Path > ,
123+ ) -> Result < Utf8PathBuf > {
124+ let path = self . workspace_root . join ( relative_path) ;
125+ path. read_link_utf8 ( )
126+ . with_context ( || format ! ( "failed to read link: {}" , path) )
127+ }
128+
113129 /// Check if a file exists in the workspace.
114130 pub fn file_exists ( & self , relative_path : impl AsRef < Utf8Path > ) -> bool {
115131 self . workspace_root . join ( relative_path. as_ref ( ) ) . exists ( )
@@ -199,10 +215,13 @@ impl TestEnvironment {
199215 & self ,
200216 api_ident : & str ,
201217 ) -> Result < String > {
202- self . read_file ( format ! (
203- "documents/{}/{}-latest.json" ,
204- api_ident, api_ident
205- ) )
218+ // Try reading the link to ensure it's a symlink.
219+ let file_name =
220+ format ! ( "documents/{}/{}-latest.json" , api_ident, api_ident) ;
221+ let target = self . read_link ( & file_name) ?;
222+ eprintln ! ( "** symlink target: {}" , target) ;
223+
224+ self . read_file ( & file_name)
206225 }
207226
208227 /// Commit documents to git (for blessed document workflow testing).
@@ -456,3 +475,42 @@ pub fn create_mixed_test_apis() -> Result<ManagedApis> {
456475 ] ;
457476 ManagedApis :: new ( configs) . context ( "failed to create mixed ManagedApis" )
458477}
478+
479+ /// Create versioned health API with a trivial change (title/metadata updated).
480+ pub fn create_versioned_health_test_apis_with_trivial_change ( )
481+ -> Result < ManagedApis > {
482+ // Create a modified API config that would produce different OpenAPI documents.
483+ let mut config = versioned_health_test_api ( ) ;
484+
485+ // Modify the title to create a different document signature.
486+ config. title = "Modified Versioned Health API" ;
487+ config. metadata . description =
488+ Some ( "A versioned health API with breaking changes" ) ;
489+
490+ ManagedApis :: new ( vec ! [ config] )
491+ . context ( "failed to create trivial change versioned health ManagedApis" )
492+ }
493+
494+ /// Create versioned health API with reduced versions (simulating version removal).
495+ pub fn create_versioned_health_test_apis_reduced_versions ( )
496+ -> Result < ManagedApis > {
497+ // Create a configuration similar to versioned health but with fewer versions.
498+ // We'll create a new fixture for this.
499+ let config = ManagedApiConfig {
500+ ident : "versioned-health" ,
501+ versions : Versions :: Versioned {
502+ // Use a subset of versions (only 1.0.0 and 2.0.0, not 3.0.0).
503+ supported_versions : fixtures:: versioned_health_reduced:: supported_versions ( ) ,
504+ } ,
505+ title : "Versioned Health API" ,
506+ metadata : ManagedApiMetadata {
507+ description : Some ( "A versioned health API with reduced versions" ) ,
508+ ..Default :: default ( )
509+ } ,
510+ api_description : fixtures:: versioned_health_reduced:: versioned_health_api_mod:: stub_api_description,
511+ extra_validation : None ,
512+ } ;
513+
514+ ManagedApis :: new ( vec ! [ config] )
515+ . context ( "failed to create reduced versioned health ManagedApis" )
516+ }
0 commit comments