summaryrefslogtreecommitdiff
path: root/service/reload/config_test.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-02-21 18:02:33 +0300
committerValery Piashchynski <[email protected]>2020-02-21 18:02:33 +0300
commitb2a19749a3e02f38c50e9023a22c60b679933c97 (patch)
treed192af0c58907ce110ab3bdcb1dd839196a02d8b /service/reload/config_test.go
parentb44167f66258712df47c21896961756f8be672df (diff)
Add tests
Add reload tests to Makefile Remove old code
Diffstat (limited to 'service/reload/config_test.go')
-rw-r--r--service/reload/config_test.go58
1 files changed, 58 insertions, 0 deletions
diff --git a/service/reload/config_test.go b/service/reload/config_test.go
index 7cad4a5d..dd9a2797 100644
--- a/service/reload/config_test.go
+++ b/service/reload/config_test.go
@@ -1 +1,59 @@
package reload
+
+import (
+ "github.com/stretchr/testify/assert"
+ "testing"
+ "time"
+)
+
+func Test_Config_Valid(t *testing.T) {
+ services := make(map[string]ServiceConfig)
+ services["test"] = ServiceConfig{
+ Recursive: false,
+ Patterns: nil,
+ Dirs: nil,
+ Ignore: nil,
+ service: nil,
+ }
+
+ cfg := &Config{
+ Enabled: true,
+ Interval: time.Second,
+ Patterns: nil,
+ Services: services,
+ }
+ assert.NoError(t, cfg.Valid())
+}
+
+func Test_Fake_ServiceConfig(t *testing.T) {
+ services := make(map[string]ServiceConfig)
+ cfg := &Config{
+ Enabled: true,
+ Interval: time.Second,
+ Patterns: nil,
+ Services: services,
+ }
+ assert.Error(t, cfg.Valid())
+}
+
+func Test_Interval(t *testing.T) {
+ services := make(map[string]ServiceConfig)
+ cfg := &Config{
+ Enabled: true,
+ Interval: time.Millisecond,
+ Patterns: nil,
+ Services: services,
+ }
+ assert.Error(t, cfg.Valid())
+}
+
+func Test_NoServiceConfig(t *testing.T) {
+ services := make(map[string]ServiceConfig)
+ cfg := &Config{
+ Enabled: true,
+ Interval: time.Millisecond,
+ Patterns: nil,
+ Services: services,
+ }
+ assert.Error(t, cfg.Valid())
+} \ No newline at end of file