| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											2020-08-22 01:52:00 +01:00
										 |  |  |   describe "single_package_query", :needs_network 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-06-30 08:51:33 +01:00
										 |  |  |       expect(response).to be_nil | 
					
						
							|  |  |  |       # TODO: uncomment (and remove line above) when we have a fix for Repology | 
					
						
							|  |  |  |       # `curl` issues | 
					
						
							|  |  |  |       # expect(response).not_to be_nil | 
					
						
							|  |  |  |       # expect(response).to be_a(Hash) | 
					
						
							| 
									
										
										
										
											2020-08-03 11:21:50 -05:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-22 01:52:00 +01:00
										 |  |  |   describe "parse_api_response", :needs_network 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-02-17 00:09:02 +05:30
										 |  |  |       response = described_class.parse_api_response(limit, 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 |