-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentry_test.go
55 lines (42 loc) · 1.06 KB
/
entry_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
55
package confy
import (
"os"
"testing"
)
func TestMain(m *testing.M) {
level.Set(LoggingDisabled)
code := m.Run()
os.Exit(code)
}
func TestConfigBasic(t *testing.T) {
os.Args = []string{
"dummyprogramname",
"-marshal", "test marshalling",
"-thonku_complex.Mff", "innername:42",
"-my_boy", "2024-11-09T15:04:05Z", // Example for time.Time
"-basic_array", "item1,item2,item3", // Example for BasicArray
"-complex_array", "text1,text2,text3", // Example for ComplexArray (implementsTextUnmarshaler)
}
_, _, err := Config[testStruct](DefaultsFromPath("testdata/test.json"))
if err != nil {
t.Fatal(err)
}
}
func TestConfigurationNothingSet(t *testing.T) {
os.Args = []string{
"dummy",
}
_, _, err := Config[testStruct](Defaults("config", "config.yaml"))
if err == nil {
t.Fatal("should return that help was asked for")
}
}
func TestConfigurationHelp(t *testing.T) {
os.Args = []string{
"dummy", "-h",
}
_, _, err := Config[testStruct](Defaults("config", "config.yaml"))
if err == nil {
t.Fatal("should return that help was asked for")
}
}