summaryrefslogtreecommitdiff
path: root/srv/src/cfg/cfg_test.go
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2022-05-17 11:56:17 -0600
committerBrian Picciano <mediocregopher@gmail.com>2022-05-17 11:56:17 -0600
commit4d2332582355c0b4c70d7817e569139d502d97a1 (patch)
tree07d8778811f625ec46b6b0c79af252f393ee4d52 /srv/src/cfg/cfg_test.go
parent788aba3d0d0bc98c0164f87cf3a4941cf4587a54 (diff)
Implement cfg.BoolVar method
Diffstat (limited to 'srv/src/cfg/cfg_test.go')
-rw-r--r--srv/src/cfg/cfg_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/srv/src/cfg/cfg_test.go b/srv/src/cfg/cfg_test.go
index 7ccf94a..8266c89 100644
--- a/srv/src/cfg/cfg_test.go
+++ b/srv/src/cfg/cfg_test.go
@@ -44,3 +44,24 @@ func TestIntVar(t *testing.T) {
assert.Equal(t, 222, bar)
assert.Equal(t, 333, baz)
}
+
+func TestBoolVar(t *testing.T) {
+
+ cfg := New(Params{
+ Args: []string{"--foo=1"},
+ Env: map[string]string{"FOO": "0", "BAR": "anything", "BIZ": "0"},
+ })
+
+ var foo, bar, baz, biz bool
+
+ cfg.BoolVar(&foo, "foo", false, "")
+ cfg.BoolVar(&bar, "bar", false, "")
+ cfg.BoolVar(&baz, "baz", false, "")
+ cfg.BoolVar(&biz, "biz", true, "")
+
+ assert.NoError(t, cfg.Init(context.Background()))
+ assert.Equal(t, true, foo)
+ assert.Equal(t, true, bar)
+ assert.Equal(t, false, baz)
+ assert.Equal(t, false, biz)
+}