diff options
author | Valery Piashchynski <[email protected]> | 2020-12-14 11:35:32 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-12-14 11:35:32 +0300 |
commit | 909076dbf20dce19207d338ca3f5c931953b64a6 (patch) | |
tree | dd5c25106e5dfc724102397a357cc2cf8f42a885 /plugins/reload/config_test.go | |
parent | 673da74925dee5c62064d3304289ae81cb499217 (diff) |
Initial commit
Diffstat (limited to 'plugins/reload/config_test.go')
-rw-r--r-- | plugins/reload/config_test.go | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/plugins/reload/config_test.go b/plugins/reload/config_test.go new file mode 100644 index 00000000..600975d3 --- /dev/null +++ b/plugins/reload/config_test.go @@ -0,0 +1,63 @@ +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{ + 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{ + Interval: time.Microsecond, + Patterns: nil, + Services: services, + } + assert.Error(t, cfg.Valid()) +} + +func Test_Interval(t *testing.T) { + services := make(map[string]ServiceConfig) + services["test"] = ServiceConfig{ + Enabled: false, + Recursive: false, + Patterns: nil, + Dirs: nil, + Ignore: nil, + service: nil, + } + + cfg := &Config{ + Interval: time.Millisecond, // should crash here + Patterns: nil, + Services: services, + } + assert.Error(t, cfg.Valid()) +} + +func Test_NoServiceConfig(t *testing.T) { + cfg := &Config{ + Interval: time.Second, + Patterns: nil, + Services: nil, + } + assert.Error(t, cfg.Valid()) +} |