@@ -54,11 +54,6 @@ class ConfigurationTest < ActiveSupport::TestCase
5454 assert_processes configuration , :worker , 2
5555 end
5656
57- test "max number of threads" do
58- configuration = SolidQueue ::Configuration . new
59- assert 7 , configuration . max_number_of_threads
60- end
61-
6257 test "mulitple workers with the same configuration" do
6358 background_worker = { queues : "background" , polling_interval : 10 , processes : 3 }
6459 configuration = SolidQueue ::Configuration . new ( workers : [ background_worker ] )
@@ -90,22 +85,30 @@ class ConfigurationTest < ActiveSupport::TestCase
9085 assert_processes configuration , :dispatcher , 1 , polling_interval : 0.1 , recurring_tasks : nil
9186 end
9287
93- test "detects when there are invalid recurring tasks" do
88+ test "validate configuration" do
89+ # Valid and invalid recurring tasks
9490 configuration = SolidQueue ::Configuration . new ( recurring_schedule_file : config_file_path ( :recurring_with_invalid ) )
95-
9691 assert_not configuration . valid?
97- end
92+ assert configuration . errors . full_messages . one?
93+ error = configuration . errors . full_messages . first
9894
99- test "is valid when there are no recurring tasks" do
100- configuration = SolidQueue ::Configuration . new ( recurring_schedule_file : config_file_path ( :empty_recurring ) )
95+ assert error . include? ( "Invalid recurring tasks" )
96+ assert error . include? ( "periodic_invalid_class: Class name doesn't correspond to an existing class" )
97+ assert error . include? ( "periodic_incorrect_schedule: Schedule is not a supported recurring schedule" )
10198
102- assert configuration . valid?
103- end
99+ assert SolidQueue :: Configuration . new ( recurring_schedule_file : config_file_path ( :empty_recurring ) ) . valid?
100+ assert SolidQueue :: Configuration . new ( skip_recurring : true ) . valid?
104101
105- test "is valid when recurring tasks are skipped" do
106- configuration = SolidQueue ::Configuration . new ( skip_recurring : true )
102+ # No processes
103+ configuration = SolidQueue ::Configuration . new ( skip_recurring : true , dispatchers : [ ] , workers : [ ] )
104+ assert_not configuration . valid?
105+ assert_equal [ "No processes configured" ] , configuration . errors . full_messages
107106
108- assert configuration . valid?
107+ # Not enough DB connections
108+ configuration = SolidQueue ::Configuration . new ( workers : [ { queues : "background" , threads : 50 , polling_interval : 10 } ] )
109+ assert_not configuration . valid?
110+ assert_match /Solid Queue is configured to use \d + threads but the database connection pool is \d +. Increase it in `config\/ database.yml`/ ,
111+ configuration . errors . full_messages . first
109112 end
110113
111114 private
0 commit comments