-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper_test.go
71 lines (53 loc) · 1.31 KB
/
helper_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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"os"
"testing"
)
func TestGetEnvVariables(t *testing.T) {
os.Setenv("password", "test")
os.Setenv("years", "abc")
_, _, _, _, err := GetEnvVariables()
if err == nil {
t.Error("Email is supposed to be invalid")
}
os.Clearenv()
os.Setenv("email", "test@gmail.com")
os.Setenv("years", "abc")
_, _, _, _, err = GetEnvVariables()
if err == nil {
t.Error("Password is supposed to be invalid")
}
os.Clearenv()
os.Setenv("email", "test@gmail.com")
os.Setenv("password", "test")
_, _, _, _, err = GetEnvVariables()
if err == nil {
t.Error("Year is supposed to be invalid")
}
os.Clearenv()
os.Setenv("email", "test@gmail.com")
os.Setenv("password", "test")
os.Setenv("years", "1")
_, _, _, _, err = GetEnvVariables()
if err == nil {
t.Error("Path is supposed to be invalid")
}
os.Clearenv()
os.Setenv("email", "test@gmail.com")
os.Setenv("password", "test")
os.Setenv("path", "test")
os.Setenv("years", "abc")
_, _, _, _, err = GetEnvVariables()
if err == nil {
t.Error("Year is supposed to be invalid")
}
os.Clearenv()
os.Setenv("email", "test@gmail.com")
os.Setenv("password", "test")
os.Setenv("path", "test")
os.Setenv("years", "1")
_, _, _, _, err = GetEnvVariables()
if err != nil {
t.Error("All environment variables are supposed to be valid")
}
}