@@ -5,7 +5,7 @@ defmodule Mix.Tasks.App.StartTest do
5
5
6
6
defmodule AppStartSample do
7
7
def project do
8
- [ app: :app_start_sample , version: "0.1.0" ]
8
+ [ app: :app_start_sample , version: "0.1.0" , start_permanent: true ]
9
9
end
10
10
11
11
def application do
@@ -89,7 +89,14 @@ defmodule Mix.Tasks.App.StartTest do
89
89
end
90
90
91
91
test "start does nothing if app is nil" do
92
- assert Mix.Tasks.App.Start . start ( nil ) == :error
92
+ assert Mix.Tasks.App.Start . start ( [ app: nil ] , [ ] ) == :error
93
+ end
94
+
95
+ test "allows type to be configured" do
96
+ assert Mix.Tasks.App.Start . type ( [ ] , [ permanent: true ] ) == :permanent
97
+ assert Mix.Tasks.App.Start . type ( [ ] , [ temporary: true ] ) == :temporary
98
+ assert Mix.Tasks.App.Start . type ( [ start_permanent: true ] , [ ] ) == :permanent
99
+ assert Mix.Tasks.App.Start . type ( [ ] , [ ] ) == :temporary
93
100
end
94
101
95
102
defmodule ReturnSample do
@@ -115,9 +122,12 @@ defmodule Mix.Tasks.App.StartTest do
115
122
Process . put ( :application_definition , mod: { ReturnApp , { :error , :bye } } )
116
123
Mix.Tasks.Compile . run [ ]
117
124
118
- assert_raise Mix.Error , "Could not start application return_sample: Mix.Tasks.App.StartTest.ReturnApp.start(:normal, {:error, :bye}) returned an error: :bye" ,
119
- fn ->
120
- Mix.Tasks.App.Start . start ( :return_sample )
125
+ message = "Could not start application return_sample: " <>
126
+ "Mix.Tasks.App.StartTest.ReturnApp.start(:normal, {:error, :bye}) " <>
127
+ "returned an error: :bye"
128
+
129
+ assert_raise Mix.Error , message , fn ->
130
+ Mix.Tasks.App.Start . start ( [ app: :return_sample ] , [ ] )
121
131
end
122
132
end
123
133
end
@@ -130,10 +140,14 @@ defmodule Mix.Tasks.App.StartTest do
130
140
{ :badarg , [ { ReturnApp , :start , 2 , [ ] } ] } } } )
131
141
Mix.Tasks.Compile . run [ ]
132
142
133
- assert_raise Mix.Error , "Could not start application return_sample: Mix.Tasks.App.StartTest.ReturnApp.start(:normal, {:error, {:badarg, [{Mix.Tasks.App.StartTest.ReturnApp, :start, 2, []}]}}) returned an error: an exception was raised:\n " <>
134
- " ** (ArgumentError) argument error\n " <>
135
- " Mix.Tasks.App.StartTest.ReturnApp.start/2" , fn ->
136
- Mix.Tasks.App.Start . start ( :return_sample )
143
+ message = "Could not start application return_sample: " <>
144
+ "Mix.Tasks.App.StartTest.ReturnApp.start(:normal, {:error, {:badarg, [{Mix.Tasks.App.StartTest.ReturnApp, :start, 2, []}]}}) " <>
145
+ "returned an error: an exception was raised:\n " <>
146
+ " ** (ArgumentError) argument error\n " <>
147
+ " Mix.Tasks.App.StartTest.ReturnApp.start/2"
148
+
149
+ assert_raise Mix.Error , message , fn ->
150
+ Mix.Tasks.App.Start . start ( [ app: :return_sample ] , [ ] )
137
151
end
138
152
end
139
153
end
@@ -145,9 +159,12 @@ defmodule Mix.Tasks.App.StartTest do
145
159
Process . put ( :application_definition , mod: { ReturnApp , :bad } )
146
160
Mix.Tasks.Compile . run [ ]
147
161
148
- assert_raise Mix.Error , "Could not start application return_sample: Mix.Tasks.App.StartTest.ReturnApp.start(:normal, :bad) returned a bad value: :bad" ,
149
- fn ->
150
- Mix.Tasks.App.Start . start ( :return_sample )
162
+ message = "Could not start application return_sample: " <>
163
+ "Mix.Tasks.App.StartTest.ReturnApp.start(:normal, :bad) " <>
164
+ "returned a bad value: :bad"
165
+
166
+ assert_raise Mix.Error , message , fn ->
167
+ Mix.Tasks.App.Start . start ( [ app: :return_sample ] , [ ] )
151
168
end
152
169
end
153
170
end
@@ -175,10 +192,12 @@ defmodule Mix.Tasks.App.StartTest do
175
192
Process . put ( :application_definition , mod: { ExitApp , :bye } )
176
193
Mix.Tasks.Compile . run [ ]
177
194
178
- assert_raise Mix.Error , "Could not start application exit_sample: exited in: Mix.Tasks.App.StartTest.ExitApp.start(:normal, :bye)\n " <>
179
- " ** (EXIT) :bye" ,
180
- fn ->
181
- Mix.Tasks.App.Start . start ( :exit_sample )
195
+ message = "Could not start application exit_sample: exited in: " <>
196
+ "Mix.Tasks.App.StartTest.ExitApp.start(:normal, :bye)\n " <>
197
+ " ** (EXIT) :bye"
198
+
199
+ assert_raise Mix.Error , message , fn ->
200
+ Mix.Tasks.App.Start . start ( [ app: :exit_sample ] , [ ] )
182
201
end
183
202
end
184
203
end
@@ -190,10 +209,12 @@ defmodule Mix.Tasks.App.StartTest do
190
209
Process . put ( :application_definition , mod: { ExitApp , :normal } )
191
210
Mix.Tasks.Compile . run [ ]
192
211
193
- assert_raise Mix.Error , "Could not start application exit_sample: exited in: Mix.Tasks.App.StartTest.ExitApp.start(:normal, :normal)\n " <>
194
- " ** (EXIT) normal" ,
195
- fn ->
196
- Mix.Tasks.App.Start . start ( :exit_sample )
212
+ message = "Could not start application exit_sample: exited in: " <>
213
+ "Mix.Tasks.App.StartTest.ExitApp.start(:normal, :normal)\n " <>
214
+ " ** (EXIT) normal"
215
+
216
+ assert_raise Mix.Error , message , fn ->
217
+ Mix.Tasks.App.Start . start ( [ app: :exit_sample ] , [ ] )
197
218
end
198
219
end
199
220
end
0 commit comments