summaryrefslogtreecommitdiff
path: root/plugins/reload/tests/config_test.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-12-15 17:59:20 +0300
committerValery Piashchynski <[email protected]>2020-12-15 17:59:20 +0300
commit089a202aa716f3510402ff8baf47a3b9bfaefcb8 (patch)
treec0d889ab896804da239dd3e1bd16de0bdd70e379 /plugins/reload/tests/config_test.go
parent21b51367e27f5a1b166459a115e4655d07a5d832 (diff)
Update reloader to support new container
Diffstat (limited to 'plugins/reload/tests/config_test.go')
-rw-r--r--plugins/reload/tests/config_test.go63
1 files changed, 63 insertions, 0 deletions
diff --git a/plugins/reload/tests/config_test.go b/plugins/reload/tests/config_test.go
new file mode 100644
index 00000000..5bb64b6b
--- /dev/null
+++ b/plugins/reload/tests/config_test.go
@@ -0,0 +1,63 @@
+package tests
+
+import (
+ "testing"
+ "time"
+
+ "github.com/spiral/roadrunner/v2/plugins/reload"
+ "github.com/stretchr/testify/assert"
+)
+
+func Test_Config_Valid(t *testing.T) {
+ services := make(map[string]reload.ServiceConfig)
+ services["test"] = reload.ServiceConfig{
+ Recursive: false,
+ Patterns: nil,
+ Dirs: nil,
+ Ignore: nil,
+ }
+
+ cfg := &reload.Config{
+ Interval: time.Second,
+ Patterns: nil,
+ Services: services,
+ }
+ assert.NoError(t, cfg.Valid())
+}
+
+func Test_Fake_ServiceConfig(t *testing.T) {
+ services := make(map[string]reload.ServiceConfig)
+ cfg := &reload.Config{
+ Interval: time.Microsecond,
+ Patterns: nil,
+ Services: services,
+ }
+ assert.Error(t, cfg.Valid())
+}
+
+func Test_Interval(t *testing.T) {
+ services := make(map[string]reload.ServiceConfig)
+ services["test"] = reload.ServiceConfig{
+ Enabled: false,
+ Recursive: false,
+ Patterns: nil,
+ Dirs: nil,
+ Ignore: nil,
+ }
+
+ cfg := &reload.Config{
+ Interval: time.Millisecond, // should crash here
+ Patterns: nil,
+ Services: services,
+ }
+ assert.Error(t, cfg.Valid())
+}
+
+func Test_NoServiceConfig(t *testing.T) {
+ cfg := &reload.Config{
+ Interval: time.Second,
+ Patterns: nil,
+ Services: nil,
+ }
+ assert.Error(t, cfg.Valid())
+}