@@ -132,6 +132,39 @@ defmodule Mix.Tasks.ArchiveTest do
132132 end
133133 end
134134
135+ test "archive check" do
136+ # Install the archive
137+ in_fixture "archive" , fn ( ) ->
138+ Mix.Tasks.Archive.Build . run [ "--no-elixir-version-check" ]
139+ send self , { :mix_shell_input , :yes? , true }
140+ Mix.Tasks.Archive.Install . run [ ]
141+ end
142+
143+ assert_raise Mix.Error , ~r/ Expected archive to be in the format/ , fn ->
144+ archive_check [ :archive ]
145+ end
146+
147+ assert_raise Mix.Error , ~r/ Archive "archive" could not be found/ , fn ->
148+ archive_check [ { :archive , ">= 1.0.0" } ]
149+ end
150+
151+ # Load the archive
152+ Mix.Local . append_archives
153+
154+ assert_raise Mix.Error , ~r/ Archive \" archive-0.1.0\" does not match requirement >= 1.0.0/ , fn ->
155+ archive_check [ { :archive , ">= 1.0.0" } ]
156+ end
157+
158+ archive_check [ { :archive , ">= 0.0.0" } ]
159+ end
160+
161+ defp archive_check ( archives ) do
162+ Mix.Project . pop
163+ Mix.ProjectStack . post_config archives: archives
164+ Mix.Project . push MixTest.Case.Sample
165+ Mix.Tasks.Archive.Check . run ( [ ] )
166+ end
167+
135168 defp sha512 ( file ) do
136169 Base . encode16 :crypto . hash ( :sha512 , File . read! ( file ) ) , case: :lower
137170 end
0 commit comments