-
Notifications
You must be signed in to change notification settings - Fork 1
/
dotenv_test.go
43 lines (37 loc) · 911 Bytes
/
dotenv_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
package dotenv
import (
"os"
"testing"
)
func assertEnvValue(t *testing.T, name, want string) {
got := os.Getenv(name)
if got != want {
t.Errorf("Want <%v> but got <%v>\n", want, got)
}
os.Unsetenv(name)
}
func TestGoQuoted(t *testing.T) {
err := GoWithPath("fixtures/quoted.env")
if err != nil {
t.Error(err)
}
assertEnvValue(t, "QUOTED", "true")
assertEnvValue(t, "OPTION_A", "1")
assertEnvValue(t, "OPTION_B", "2")
assertEnvValue(t, "OPTION_C", "")
assertEnvValue(t, "OPTION_D", "\n")
assertEnvValue(t, "OPTION_E", "1")
assertEnvValue(t, "OPTION_F", "2")
assertEnvValue(t, "OPTION_G", "")
assertEnvValue(t, "OPTION_H", "\n")
}
func TestGoComments(t *testing.T) {
err := GoWithPath("fixtures/comments.env")
if err != nil {
t.Error(err)
}
assertEnvValue(t, "COMMENT", "")
assertEnvValue(t, "#COMMENT", "")
assertEnvValue(t, "PLAIN", "true")
assertEnvValue(t, "ARG", "1")
}