| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  | # typed: false | 
					
						
							|  |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | require "software_spec" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe BottleSpecification do | 
					
						
							|  |  |  |   subject(:bottle_spec) { described_class.new } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe "#sha256" do | 
					
						
							|  |  |  |     it "works without cellar" do | 
					
						
							|  |  |  |       checksums = { | 
					
						
							| 
									
										
										
										
											2021-04-08 13:45:15 +01:00
										 |  |  |         arm64_big_sur: "deadbeef" * 8, | 
					
						
							|  |  |  |         big_sur:       "faceb00c" * 8, | 
					
						
							|  |  |  |         catalina:      "baadf00d" * 8, | 
					
						
							|  |  |  |         mojave:        "8badf00d" * 8, | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       checksums.each_pair do |cat, digest| | 
					
						
							| 
									
										
										
										
											2021-04-09 09:30:36 +01:00
										 |  |  |         bottle_spec.sha256(cat => digest) | 
					
						
							| 
									
										
										
										
											2021-09-16 18:56:47 +01:00
										 |  |  |         tag_spec = bottle_spec.tag_specification_for(Utils::Bottles::Tag.from_symbol(cat)) | 
					
						
							|  |  |  |         expect(Checksum.new(digest)).to eq(tag_spec.checksum) | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "works with cellar" do | 
					
						
							|  |  |  |       checksums = [ | 
					
						
							| 
									
										
										
										
											2021-04-08 13:45:15 +01:00
										 |  |  |         { cellar: :any_skip_relocation, tag: :arm64_big_sur,  digest: "deadbeef" * 8 }, | 
					
						
							|  |  |  |         { cellar: :any, tag: :big_sur, digest: "faceb00c" * 8 }, | 
					
						
							|  |  |  |         { cellar: "/usr/local/Cellar", tag: :catalina, digest: "baadf00d" * 8 }, | 
					
						
							|  |  |  |         { cellar: Homebrew::DEFAULT_CELLAR, tag: :mojave, digest: "8badf00d" * 8 }, | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |       ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       checksums.each do |checksum| | 
					
						
							| 
									
										
										
										
											2021-04-09 09:30:36 +01:00
										 |  |  |         bottle_spec.sha256(cellar: checksum[:cellar], checksum[:tag] => checksum[:digest]) | 
					
						
							| 
									
										
										
										
											2021-09-16 18:56:47 +01:00
										 |  |  |         tag_spec = bottle_spec.tag_specification_for(Utils::Bottles::Tag.from_symbol(checksum[:tag])) | 
					
						
							|  |  |  |         expect(Checksum.new(checksum[:digest])).to eq(tag_spec.checksum) | 
					
						
							|  |  |  |         expect(checksum[:tag]).to eq(tag_spec.tag.to_sym) | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |         checksum[:cellar] ||= Homebrew::DEFAULT_CELLAR | 
					
						
							| 
									
										
										
										
											2021-09-16 18:56:47 +01:00
										 |  |  |         expect(checksum[:cellar]).to eq(tag_spec.cellar) | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-09 09:30:36 +01:00
										 |  |  |   %w[root_url rebuild].each do |method| | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |     specify "##{method}" do | 
					
						
							|  |  |  |       object = Object.new | 
					
						
							|  |  |  |       bottle_spec.public_send(method, object) | 
					
						
							|  |  |  |       expect(bottle_spec.public_send(method)).to eq(object) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |