-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgodotenv_test.go
More file actions
55 lines (41 loc) · 1.34 KB
/
godotenv_test.go
File metadata and controls
55 lines (41 loc) · 1.34 KB
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 godotenv
import (
"embed"
"testing"
"github.com/stretchr/testify/assert"
)
//go:embed envs/*
var envFS embed.FS
func Test_In_UnParallel(t *testing.T) {
t.Parallel()
err := testLoadShouldGetEmbeddedLocalEnvFileSuccessfully()
assert.Nil(t, err)
assert.Equal(t, "local.1.0", Get("version"))
err = testLoadShouldGetEmbeddedLiveeEnvFileSuccessfully()
assert.Nil(t, err)
assert.Equal(t, "live.1.0", Get("version"))
err = testLoadShouldGetEmbeddedCommonEnvFileSuccessfully()
assert.Nil(t, err)
assert.Equal(t, "abcd", Get("shared_key"))
testLoadShouldGetEmbeddedCommonAndLiveEnvFileSuccessfully()
assert.Equal(t, "abcd", Get("shared_key"))
assert.Equal(t, "live.1.0", Get("version"))
testLoadTestEnvWithoutOverwriteShouldNotBeOverwrite()
assert.Equal(t, "live.1.0", Get("version"))
}
func testLoadShouldGetEmbeddedLocalEnvFileSuccessfully() error {
return Load(envFS, "envs/.env.local")
}
func testLoadShouldGetEmbeddedLiveeEnvFileSuccessfully() error {
return Load(envFS, "envs/.env.live")
}
func testLoadShouldGetEmbeddedCommonEnvFileSuccessfully() error {
return Load(envFS, "envs/.env")
}
func testLoadShouldGetEmbeddedCommonAndLiveEnvFileSuccessfully() {
_ = Load(envFS, "envs/.env")
_ = Load(envFS, "envs/.env.live")
}
func testLoadTestEnvWithoutOverwriteShouldNotBeOverwrite() {
_ = LoadWithoutOverwrite(envFS, "envs/.env.test")
}