summaryrefslogtreecommitdiff
path: root/service/reload/config_test.go
blob: 600975d33ce91613aecb28c3dc90e3b72c7225bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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())
}