@@ -80,18 +80,6 @@ impl GitHub {
8080 } ) )
8181 }
8282
83- /// Determines if the specified URL is supported by the GitHub repository.
84- ///
85- /// # Errors
86- /// * If the URL cannot be parsed.
87- pub fn supports ( url : & str ) -> bool {
88- let Ok ( parsed_url) = Url :: parse ( url) else {
89- return false ;
90- } ;
91- let host = parsed_url. host_str ( ) . unwrap_or_default ( ) ;
92- host. contains ( "github.com" )
93- }
94-
9583 /// Gets the version from the specified tag name.
9684 ///
9785 /// # Errors
@@ -334,22 +322,11 @@ fn reqwest_client() -> ClientWithMiddleware {
334322#[ cfg( test) ]
335323mod tests {
336324 use super :: * ;
337-
338- const URL : & str = "https://github.com/theseus-rs/postgresql-binaries" ;
339-
340- #[ test]
341- fn test_supports ( ) {
342- assert ! ( GitHub :: supports( URL ) ) ;
343- }
344-
345- #[ test]
346- fn test_supports_error ( ) {
347- assert ! ( !GitHub :: supports( "https://foo.com" ) ) ;
348- }
325+ use crate :: THESEUS_POSTGRESQL_BINARIES_URL ;
349326
350327 #[ test]
351328 fn test_name ( ) {
352- let github = GitHub :: new ( URL ) . unwrap ( ) ;
329+ let github = GitHub :: new ( THESEUS_POSTGRESQL_BINARIES_URL ) . unwrap ( ) ;
353330 assert_eq ! ( "GitHub" , github. name( ) ) ;
354331 }
355332
@@ -379,7 +356,7 @@ mod tests {
379356
380357 #[ tokio:: test]
381358 async fn test_get_version ( ) -> Result < ( ) > {
382- let github = GitHub :: new ( URL ) ?;
359+ let github = GitHub :: new ( THESEUS_POSTGRESQL_BINARIES_URL ) ?;
383360 let version_req = VersionReq :: STAR ;
384361 let version = github. get_version ( & version_req) . await ?;
385362 assert ! ( version > Version :: new( 0 , 0 , 0 ) ) ;
@@ -388,7 +365,7 @@ mod tests {
388365
389366 #[ tokio:: test]
390367 async fn test_get_specific_version ( ) -> Result < ( ) > {
391- let github = GitHub :: new ( URL ) ?;
368+ let github = GitHub :: new ( THESEUS_POSTGRESQL_BINARIES_URL ) ?;
392369 let version_req = VersionReq :: parse ( "=16.3.0" ) ?;
393370 let version = github. get_version ( & version_req) . await ?;
394371 assert_eq ! ( Version :: new( 16 , 3 , 0 ) , version) ;
@@ -397,7 +374,7 @@ mod tests {
397374
398375 #[ tokio:: test]
399376 async fn test_get_specific_not_found ( ) -> Result < ( ) > {
400- let github = GitHub :: new ( URL ) ?;
377+ let github = GitHub :: new ( THESEUS_POSTGRESQL_BINARIES_URL ) ?;
401378 let version_req = VersionReq :: parse ( "=0.0.0" ) ?;
402379 let error = github. get_version ( & version_req) . await . unwrap_err ( ) ;
403380 assert_eq ! ( "version not found for '=0.0.0'" , error. to_string( ) ) ;
@@ -410,7 +387,7 @@ mod tests {
410387
411388 #[ tokio:: test]
412389 async fn test_get_archive ( ) -> Result < ( ) > {
413- let github = GitHub :: new ( URL ) ?;
390+ let github = GitHub :: new ( THESEUS_POSTGRESQL_BINARIES_URL ) ?;
414391 let version_req = VersionReq :: parse ( "=16.3.0" ) ?;
415392 let archive = github. get_archive ( & version_req) . await ?;
416393 assert_eq ! (
@@ -436,25 +413,4 @@ mod tests {
436413 assert_eq ! ( Version :: new( 0 , 12 , 0 ) , version) ;
437414 Ok ( ( ) )
438415 }
439-
440- /// Test that a version with a 'v' prefix is correctly parsed; this is a common convention
441- /// for GitHub releases. Use a known PostgreSQL plugin repository for the test.
442- #[ tokio:: test]
443- async fn test_get_archive_with_v_prefix ( ) -> Result < ( ) > {
444- let github = GitHub :: new ( "https://github.com/turbot/steampipe-plugin-csv" ) ?;
445- let version_req = VersionReq :: parse ( "=0.12.0" ) ?;
446- let archive = github. get_archive ( & version_req) . await ?;
447- let name = archive. name ( ) ;
448- // Note: this plugin repository has 3 artifacts that can match:
449- // steampipe_export...
450- // steampipe_postgres...
451- // steampipe_sqlite...
452- // custom matchers will be needed to disambiguate plugins
453- assert ! ( name. starts_with( "steampipe_" ) ) ;
454- assert ! ( name. contains( "csv" ) ) ;
455- assert ! ( name. ends_with( ".tar.gz" ) ) ;
456- assert_eq ! ( & Version :: new( 0 , 12 , 0 ) , archive. version( ) ) ;
457- assert ! ( !archive. bytes( ) . is_empty( ) ) ;
458- Ok ( ( ) )
459- }
460416}
0 commit comments