-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
conf_test.go
54 lines (47 loc) · 1.15 KB
/
conf_test.go
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
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.
package azuread
import (
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestConf_Validate(t *testing.T) {
tests := map[string]struct {
In conf
WantErr string
}{
"default": {
In: defaultConf(),
WantErr: "",
},
"err-invalid-intervals": {
In: conf{
SyncInterval: time.Second,
UpdateInterval: time.Second * 2,
},
WantErr: "sync_interval must be longer than update_interval",
},
"err-invalid-dataset": {
In: conf{
SyncInterval: defaultSyncInterval,
UpdateInterval: defaultUpdateInterval,
Dataset: "everything",
},
WantErr: "dataset must be 'all', 'users', 'devices' or empty",
},
}
for name, tc := range tests {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()
gotErr := tc.In.Validate()
if tc.WantErr == "" {
require.NoError(t, gotErr)
} else {
require.ErrorContains(t, gotErr, tc.WantErr)
}
})
}
}