-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathreport_test.go
More file actions
54 lines (42 loc) · 1.38 KB
/
report_test.go
File metadata and controls
54 lines (42 loc) · 1.38 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
package envstruct_test
import (
"bytes"
"github.com/bradylove/envstruct"
"os"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Report", func() {
var (
ts SmallTestStruct
outputText string
)
Describe("Report()", func() {
BeforeEach(func() {
for k, v := range baseEnvVars {
os.Setenv(k, v)
}
err := envstruct.Load(&ts)
Expect(err).ToNot(HaveOccurred())
outputBuffer := bytes.NewBuffer(nil)
envstruct.ReportWriter = outputBuffer
err = envstruct.WriteReport(&ts)
Expect(err).ToNot(HaveOccurred())
outputText = string(outputBuffer.Bytes())
})
It("prints a report of the given envstruct struct", func() {
Expect(outputText).To(Equal(expectedReportOutput))
})
})
})
const (
expectedReportOutput = `FIELD NAME: TYPE: ENV: REQUIRED: VALUE:
HiddenThing string HIDDEN_THING false (OMITTED)
StringThing string STRING_THING false stringy thingy
BoolThing bool BOOL_THING false true
IntThing int INT_THING false 100
URLThing *url.URL URL_THING false &{http <nil> github.com /some/path false }
StringSliceThing []string STRING_SLICE_THING false [one two three]
CaseSensitiveThing string CASE_SENSITIVE_THING false case sensitive
`
)