@@ -2091,160 +2091,160 @@ pub fn get_file_sha(content: &ContentItems) -> Option<String> {
2091
2091
}
2092
2092
}
2093
2093
2094
- #[ cfg( test) ]
2095
- mod tests {
2096
- use super :: * ;
2097
- use env_logger:: { Builder , Env } ;
2098
- use tokio:: time:: { sleep, Duration } ;
2099
-
2100
- static OWNER : & str = "keyko-io" ;
2101
- static REPO : & str = "test-philip-second" ;
2102
-
2103
- #[ tokio:: test]
2104
- async fn end_to_end ( ) {
2105
- // Set logging
2106
- Builder :: from_env ( Env :: default ( ) . default_filter_or ( "info" ) ) . init ( ) ;
2107
- log:: info!( "Starting end-to-end test" ) ;
2108
-
2109
- // Test Creating an application
2110
- let _ = fplus_database:: setup_test_environment ( ) . await ;
2111
- let gh = github_async_new ( OWNER . to_string ( ) , REPO . to_string ( ) ) . await ;
2112
-
2113
- log:: info!( "Creating a new LDNApplication from issue" ) ;
2114
- let ldn_application: LDNApplication = match LDNApplication :: new_from_issue ( CreateApplicationInfo {
2115
- issue_number : "37" . to_string ( ) ,
2116
- owner : OWNER . to_string ( ) ,
2117
- repo : REPO . to_string ( )
2118
- } )
2119
- . await
2120
- {
2121
- Ok ( app) => app,
2122
- Err ( e) => {
2123
- log:: error!( "Failed to create LDNApplication: {}" , e) ;
2124
- return ;
2125
- }
2126
- } ;
2127
-
2128
- let application_id = ldn_application. application_id . to_string ( ) ;
2129
- log:: info!( "LDNApplication created with ID: {}" , application_id) ;
2130
-
2131
- // Validate file creation
2132
- log:: info!( "Validating file creation for application" ) ;
2133
- if let Err ( e) = gh
2134
- . get_file ( & ldn_application. file_name , & ldn_application. branch_name )
2135
- . await
2136
- {
2137
- log:: warn!(
2138
- "File validation failed for application ID {}: {}" ,
2139
- application_id,
2140
- e
2141
- ) ;
2142
- }
2143
-
2144
- // Validate pull request creation
2145
- log:: info!( "Validating pull request creation for application" ) ;
2146
- if let Err ( e) = gh
2147
- . get_pull_request_by_head ( & LDNPullRequest :: application_branch_name (
2148
- application_id. as_str ( ) ,
2149
- ) )
2150
- . await
2151
- {
2152
- log:: warn!(
2153
- "Pull request validation failed for application ID {}: {}" ,
2154
- application_id,
2155
- e
2156
- ) ;
2157
- }
2158
-
2159
- sleep ( Duration :: from_millis ( 2000 ) ) . await ;
2160
-
2161
- // Test Triggering an application
2162
- log:: info!( "Loading application for triggering" ) ;
2163
- let ldn_application_before_trigger =
2164
- match LDNApplication :: load ( application_id. clone ( ) , OWNER . to_string ( ) , REPO . to_string ( ) ) . await {
2165
- Ok ( app) => app,
2166
- Err ( e) => {
2167
- log:: error!( "Failed to load application for triggering: {}" , e) ;
2168
- return ;
2169
- }
2170
- } ;
2171
-
2172
- log:: info!( "Completing governance review" ) ;
2173
- if let Err ( e) = ldn_application_before_trigger
2174
- . complete_governance_review (
2175
- "actor_address" . to_string ( ) ,
2176
- OWNER . to_string ( ) ,
2177
- REPO . to_string ( ) )
2178
- . await
2179
- {
2180
- log:: error!( "Failed o complete governance review: {}" , e) ;
2181
- return ;
2182
- }
2183
-
2184
- let ldn_application_after_trigger = match LDNApplication :: load (
2185
- application_id. clone ( ) ,
2186
- OWNER . to_string ( ) ,
2187
- REPO . to_string ( )
2188
- ) . await
2189
- {
2190
- Ok ( app) => app,
2191
- Err ( e) => {
2192
- log:: error!( "Failed to load application after triggering: {}" , e) ;
2193
- return ;
2194
- }
2195
- } ;
2196
-
2197
- assert_eq ! (
2198
- ldn_application_after_trigger. app_state( ) . await . unwrap( ) ,
2199
- AppState :: ReadyToSign
2200
- ) ;
2201
- log:: info!( "Application state updated to ReadyToSign" ) ;
2202
- sleep ( Duration :: from_millis ( 2000 ) ) . await ;
2203
-
2204
- // Cleanup
2205
- log:: info!( "Starting cleanup process" ) ;
2206
- let head = & LDNPullRequest :: application_branch_name ( & application_id) ;
2207
- match gh. get_pull_request_by_head ( head) . await {
2208
- Ok ( prs) => {
2209
- if let Some ( pr) = prs. get ( 0 ) {
2210
- let number = pr. number ;
2211
- match gh. merge_pull_request ( number) . await {
2212
- Ok ( _) => log:: info!( "Merged pull request {}" , number) ,
2213
- Err ( _) => log:: info!( "Pull request {} was already merged" , number) ,
2214
- } ;
2215
- }
2216
- }
2217
- Err ( e) => log:: warn!( "Failed to get pull request by head: {}" , e) ,
2218
- } ;
2219
-
2220
- sleep ( Duration :: from_millis ( 3000 ) ) . await ;
2221
-
2222
- let file = match gh. get_file ( & ldn_application. file_name , "main" ) . await {
2223
- Ok ( f) => f,
2224
- Err ( e) => {
2225
- log:: error!( "Failed to get file: {}" , e) ;
2226
- return ;
2227
- }
2228
- } ;
2229
-
2230
- let file_sha = file. items [ 0 ] . sha . clone ( ) ;
2231
- let remove_file_request = gh
2232
- . delete_file ( & ldn_application. file_name , "main" , "remove file" , & file_sha)
2233
- . await ;
2234
- let remove_branch_request = gh
2235
- . build_remove_ref_request ( LDNPullRequest :: application_branch_name ( & application_id) )
2236
- . unwrap ( ) ;
2237
-
2238
- if let Err ( e) = gh. remove_branch ( remove_branch_request) . await {
2239
- log:: warn!( "Failed to remove branch: {}" , e) ;
2240
- }
2241
- if let Err ( e) = remove_file_request {
2242
- log:: warn!( "Failed to remove file: {}" , e) ;
2243
- }
2244
-
2245
- log:: info!(
2246
- "End-to-end test completed for application ID: {}" ,
2247
- application_id
2248
- ) ;
2249
- }
2250
- }
2094
+ // #[cfg(test)]
2095
+ // mod tests {
2096
+ // use super::*;
2097
+ // use env_logger::{Builder, Env};
2098
+ // use tokio::time::{sleep, Duration};
2099
+
2100
+ // static OWNER: &str = "keyko-io";
2101
+ // static REPO: &str = "test-philip-second";
2102
+
2103
+ // #[tokio::test]
2104
+ // async fn end_to_end() {
2105
+ // // Set logging
2106
+ // Builder::from_env(Env::default().default_filter_or("info")).init();
2107
+ // log::info!("Starting end-to-end test");
2108
+
2109
+ // // Test Creating an application
2110
+ // let _ = fplus_database::setup_test_environment().await;
2111
+ // let gh = github_async_new(OWNER.to_string(), REPO.to_string()).await;
2112
+
2113
+ // log::info!("Creating a new LDNApplication from issue");
2114
+ // let ldn_application: LDNApplication = match LDNApplication::new_from_issue(CreateApplicationInfo {
2115
+ // issue_number: "37".to_string(),
2116
+ // owner: OWNER.to_string(),
2117
+ // repo: REPO.to_string()
2118
+ // })
2119
+ // .await
2120
+ // {
2121
+ // Ok(app) => app,
2122
+ // Err(e) => {
2123
+ // log::error!("Failed to create LDNApplication: {}", e);
2124
+ // return;
2125
+ // }
2126
+ // };
2127
+
2128
+ // let application_id = ldn_application.application_id.to_string();
2129
+ // log::info!("LDNApplication created with ID: {}", application_id);
2130
+
2131
+ // // Validate file creation
2132
+ // log::info!("Validating file creation for application");
2133
+ // if let Err(e) = gh
2134
+ // .get_file(&ldn_application.file_name, &ldn_application.branch_name)
2135
+ // .await
2136
+ // {
2137
+ // log::warn!(
2138
+ // "File validation failed for application ID {}: {}",
2139
+ // application_id,
2140
+ // e
2141
+ // );
2142
+ // }
2143
+
2144
+ // // Validate pull request creation
2145
+ // log::info!("Validating pull request creation for application");
2146
+ // if let Err(e) = gh
2147
+ // .get_pull_request_by_head(&LDNPullRequest::application_branch_name(
2148
+ // application_id.as_str(),
2149
+ // ))
2150
+ // .await
2151
+ // {
2152
+ // log::warn!(
2153
+ // "Pull request validation failed for application ID {}: {}",
2154
+ // application_id,
2155
+ // e
2156
+ // );
2157
+ // }
2158
+
2159
+ // sleep(Duration::from_millis(2000)).await;
2160
+
2161
+ // // Test Triggering an application
2162
+ // log::info!("Loading application for triggering");
2163
+ // let ldn_application_before_trigger =
2164
+ // match LDNApplication::load(application_id.clone(), OWNER.to_string(), REPO.to_string()).await {
2165
+ // Ok(app) => app,
2166
+ // Err(e) => {
2167
+ // log::error!("Failed to load application for triggering: {}", e);
2168
+ // return;
2169
+ // }
2170
+ // };
2171
+
2172
+ // log::info!("Completing governance review");
2173
+ // if let Err(e) = ldn_application_before_trigger
2174
+ // .complete_governance_review(
2175
+ // "actor_address".to_string(),
2176
+ // OWNER.to_string(),
2177
+ // REPO.to_string())
2178
+ // .await
2179
+ // {
2180
+ // log::error!("Failed o complete governance review: {}", e);
2181
+ // return;
2182
+ // }
2183
+
2184
+ // let ldn_application_after_trigger = match LDNApplication::load(
2185
+ // application_id.clone(),
2186
+ // OWNER.to_string(),
2187
+ // REPO.to_string()
2188
+ // ).await
2189
+ // {
2190
+ // Ok(app) => app,
2191
+ // Err(e) => {
2192
+ // log::error!("Failed to load application after triggering: {}", e);
2193
+ // return;
2194
+ // }
2195
+ // };
2196
+
2197
+ // assert_eq!(
2198
+ // ldn_application_after_trigger.app_state().await.unwrap(),
2199
+ // AppState::ReadyToSign
2200
+ // );
2201
+ // log::info!("Application state updated to ReadyToSign");
2202
+ // sleep(Duration::from_millis(2000)).await;
2203
+
2204
+ // // Cleanup
2205
+ // log::info!("Starting cleanup process");
2206
+ // let head = &LDNPullRequest::application_branch_name(&application_id);
2207
+ // match gh.get_pull_request_by_head(head).await {
2208
+ // Ok(prs) => {
2209
+ // if let Some(pr) = prs.get(0) {
2210
+ // let number = pr.number;
2211
+ // match gh.merge_pull_request(number).await {
2212
+ // Ok(_) => log::info!("Merged pull request {}", number),
2213
+ // Err(_) => log::info!("Pull request {} was already merged", number),
2214
+ // };
2215
+ // }
2216
+ // }
2217
+ // Err(e) => log::warn!("Failed to get pull request by head: {}", e),
2218
+ // };
2219
+
2220
+ // sleep(Duration::from_millis(3000)).await;
2221
+
2222
+ // let file = match gh.get_file(&ldn_application.file_name, "main").await {
2223
+ // Ok(f) => f,
2224
+ // Err(e) => {
2225
+ // log::error!("Failed to get file: {}", e);
2226
+ // return;
2227
+ // }
2228
+ // };
2229
+
2230
+ // let file_sha = file.items[0].sha.clone();
2231
+ // let remove_file_request = gh
2232
+ // .delete_file(&ldn_application.file_name, "main", "remove file", &file_sha)
2233
+ // .await;
2234
+ // let remove_branch_request = gh
2235
+ // .build_remove_ref_request(LDNPullRequest::application_branch_name(&application_id))
2236
+ // .unwrap();
2237
+
2238
+ // if let Err(e) = gh.remove_branch(remove_branch_request).await {
2239
+ // log::warn!("Failed to remove branch: {}", e);
2240
+ // }
2241
+ // if let Err(e) = remove_file_request {
2242
+ // log::warn!("Failed to remove file: {}", e);
2243
+ // }
2244
+
2245
+ // log::info!(
2246
+ // "End-to-end test completed for application ID: {}",
2247
+ // application_id
2248
+ // );
2249
+ // }
2250
+ // }
0 commit comments