mirror of
https://github.com/Luzifer/rconfig.git
synced 2024-12-29 23:51:17 +00:00
Added testcase for using bool with ENV and default
This commit is contained in:
parent
d8a62bd35f
commit
bbd03f60c1
1 changed files with 29 additions and 0 deletions
29
bool_test.go
29
bool_test.go
|
@ -1,6 +1,8 @@
|
|||
package rconfig
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
@ -39,3 +41,30 @@ var _ = Describe("Testing bool parsing", func() {
|
|||
Expect(cfg.Test4).To(Equal(false))
|
||||
})
|
||||
})
|
||||
|
||||
var _ = Describe("Testing to set bool from ENV with default", func() {
|
||||
type t struct {
|
||||
Test1 bool `default:"true" env:"TEST1"`
|
||||
}
|
||||
|
||||
var (
|
||||
err error
|
||||
args []string
|
||||
cfg t
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
cfg = t{}
|
||||
args = []string{}
|
||||
})
|
||||
|
||||
JustBeforeEach(func() {
|
||||
os.Unsetenv("TEST1")
|
||||
err = parse(&cfg, args)
|
||||
})
|
||||
|
||||
It("should not have errored", func() { Expect(err).NotTo(HaveOccurred()) })
|
||||
It("should have the expected values", func() {
|
||||
Expect(cfg.Test1).To(Equal(true))
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue