Skip to content

Commit 978e345

Browse files
committed
make the handler_plugin_dir a required field
1 parent 1a61b8d commit 978e345

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

lib/hooks/core/config_validator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ValidationError < StandardError; end
1212

1313
# Global configuration schema
1414
GLOBAL_CONFIG_SCHEMA = Dry::Schema.Params do
15-
optional(:handler_plugin_dir).filled(:string)
15+
required(:handler_plugin_dir).filled(:string)
1616
optional(:auth_plugin_dir).maybe(:string)
1717
optional(:lifecycle_plugin_dir).maybe(:string)
1818
optional(:instruments_plugin_dir).maybe(:string)

spec/unit/lib/hooks/core/config_validator_spec.rb

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@
2424
end
2525

2626
it "returns validated configuration with minimal fields" do
27-
config = {}
27+
config = { handler_plugin_dir: "/path/to/handlers" }
2828

2929
result = described_class.validate_global_config(config)
3030

31-
expect(result).to eq({})
31+
expect(result).to eq({ handler_plugin_dir: "/path/to/handlers" })
3232
end
3333

3434
it "accepts production environment" do
35-
config = { environment: "production" }
35+
config = {
36+
environment: "production",
37+
handler_plugin_dir: "/path/to/handlers"
38+
}
3639

3740
result = described_class.validate_global_config(config)
3841

@@ -41,7 +44,10 @@
4144

4245
it "accepts valid log levels" do
4346
%w[debug info warn error].each do |log_level|
44-
config = { log_level: log_level }
47+
config = {
48+
log_level: log_level,
49+
handler_plugin_dir: "/path/to/handlers"
50+
}
4551

4652
result = described_class.validate_global_config(config)
4753

@@ -114,7 +120,8 @@
114120
it "coerces boolean-like string values" do
115121
config = {
116122
use_catchall_route: "true",
117-
normalize_headers: "1"
123+
normalize_headers: "1",
124+
handler_plugin_dir: "/path/to/handlers"
118125
}
119126

120127
result = described_class.validate_global_config(config)
@@ -138,7 +145,8 @@
138145
it "coerces string numeric values" do
139146
config = {
140147
request_limit: "1024",
141-
request_timeout: "30"
148+
request_timeout: "30",
149+
handler_plugin_dir: "/path/to/handlers"
142150
}
143151

144152
result = described_class.validate_global_config(config)
@@ -164,7 +172,10 @@
164172
end
165173

166174
it "coerces float values to integers by truncating" do
167-
config = { request_timeout: 30.5 }
175+
config = {
176+
request_timeout: 30.5,
177+
handler_plugin_dir: "/path/to/handlers"
178+
}
168179

169180
result = described_class.validate_global_config(config)
170181

0 commit comments

Comments
 (0)