| 
									
										
										
										
											2020-10-10 14:16:11 +02:00
										 |  |  | # typed: false | 
					
						
							| 
									
										
										
										
											2020-08-03 11:21:50 -05:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | require "utils/repology" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe Repology do | 
					
						
							| 
									
										
										
										
											2021-09-24 22:44:27 -04:00
										 |  |  |   describe "single_package_query", :needs_network, :needs_tls13 do | 
					
						
							| 
									
										
										
										
											2020-08-03 11:21:50 -05:00
										 |  |  |     it "returns nil for non-existent package" do | 
					
						
							| 
									
										
										
										
											2021-02-17 00:09:02 +05:30
										 |  |  |       response = described_class.single_package_query("invalidName", repository: "homebrew") | 
					
						
							| 
									
										
										
										
											2020-08-03 11:21:50 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |       expect(response).to be_nil | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "returns a hash for existing package" do | 
					
						
							| 
									
										
										
										
											2021-02-17 00:09:02 +05:30
										 |  |  |       response = described_class.single_package_query("openclonk", repository: "homebrew") | 
					
						
							| 
									
										
										
										
											2020-08-03 11:21:50 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-24 22:44:27 -04:00
										 |  |  |       expect(response).not_to be_nil | 
					
						
							|  |  |  |       expect(response).to be_a(Hash) | 
					
						
							| 
									
										
										
										
											2020-08-03 11:21:50 -05:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-24 22:44:27 -04:00
										 |  |  |   describe "parse_api_response", :needs_network, :needs_tls13 do | 
					
						
							| 
									
										
										
										
											2020-08-03 11:21:50 -05:00
										 |  |  |     it "returns a hash of data" do | 
					
						
							| 
									
										
										
										
											2020-08-22 01:52:00 +01:00
										 |  |  |       limit = 1
 | 
					
						
							| 
									
										
										
										
											2021-10-23 15:09:34 -04:00
										 |  |  |       start_with = "x" | 
					
						
							|  |  |  |       response = described_class.parse_api_response(limit, start_with, repository: "homebrew") | 
					
						
							| 
									
										
										
										
											2020-08-22 01:52:00 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-03 11:21:50 -05:00
										 |  |  |       expect(response).not_to be_nil | 
					
						
							|  |  |  |       expect(response).to be_a(Hash) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |