-
Notifications
You must be signed in to change notification settings - Fork 5
/
config_parser_test.go
52 lines (30 loc) · 1.08 KB
/
config_parser_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
package mailbear_test
import (
"testing"
"github.com/DenBeke/mailbear"
"github.com/stretchr/testify/require"
)
const (
configFile = "config_sample.yml"
nonExistingFile = "random file that does not exist"
invalidFile = "config.go"
)
func TestGetConfigFromFile(t *testing.T) {
config, err := mailbear.GetConfigFromFile(configFile)
require.NoError(t, err, "should be able to parse config file")
require.Len(t, config.Forms, 1, "should have a form in the sample config file.")
}
func TestSampleConfigFileIsValid(t *testing.T) {
config, err := mailbear.GetConfigFromFile(configFile)
require.NoError(t, err, "should be able to parse config file")
err = config.Validate()
require.NoError(t, err, "sampel config file should be valid")
}
func TestGetConfigFromFileNotExists(t *testing.T) {
_, err := mailbear.GetConfigFromFile(nonExistingFile)
require.Error(t, err, "should have error on no existing file")
}
func TestGetConfigFromFileInvalid(t *testing.T) {
_, err := mailbear.GetConfigFromFile(invalidFile)
require.Error(t, err, "should have error on non-json file")
}