@@ -54,11 +54,6 @@ class ConfigurationTest < ActiveSupport::TestCase
54
54
assert_processes configuration , :worker , 2
55
55
end
56
56
57
- test "max number of threads" do
58
- configuration = SolidQueue ::Configuration . new
59
- assert 7 , configuration . max_number_of_threads
60
- end
61
-
62
57
test "mulitple workers with the same configuration" do
63
58
background_worker = { queues : "background" , polling_interval : 10 , processes : 3 }
64
59
configuration = SolidQueue ::Configuration . new ( workers : [ background_worker ] )
@@ -90,22 +85,30 @@ class ConfigurationTest < ActiveSupport::TestCase
90
85
assert_processes configuration , :dispatcher , 1 , polling_interval : 0.1 , recurring_tasks : nil
91
86
end
92
87
93
- test "detects when there are invalid recurring tasks" do
88
+ test "validate configuration" do
89
+ # Valid and invalid recurring tasks
94
90
configuration = SolidQueue ::Configuration . new ( recurring_schedule_file : config_file_path ( :recurring_with_invalid ) )
95
-
96
91
assert_not configuration . valid?
97
- end
92
+ assert configuration . errors . full_messages . one?
93
+ error = configuration . errors . full_messages . first
98
94
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" )
101
98
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?
104
101
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
107
106
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
109
112
end
110
113
111
114
private
0 commit comments