forked from cloudfoundry-community/go-cfenv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvironment_test.go
42 lines (34 loc) · 1014 Bytes
/
environment_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
package cfenv_test
import (
"testing"
"github.com/cloud-gov/go-cfenv"
. "github.com/onsi/gomega"
"github.com/sclevine/spec"
)
func testEnvironment(t *testing.T, when spec.G, it spec.S) {
it.Before(func() {
RegisterTestingT(t)
})
when("environment variables should be mapped with default environment", func() {
it("should contain at least one mapped variable", func() {
vars := cfenv.CurrentEnv()
Expect(len(vars)).To(BeNumerically(">", 0), "Environment variables should exist")
})
it("should split variables into keys and values", func() {
vars := cfenv.CurrentEnv()
valueCount := 0
for k, v := range vars {
// Key should never be empty
Expect(k).NotTo(BeEmpty())
// Key should never have equals
Expect(k).NotTo(ContainSubstring("="))
// Value may be empty, but let's track non-empty values
if v != "" {
valueCount++
}
}
// Ensure we get at least one value from the environment
Expect(valueCount).To(BeNumerically(">", 0))
})
})
}