github.com/fern4lvarez/piladb@v0.2.0-alpha.20180407/config/vars/vars_test.go (about) 1 package vars 2 3 import "testing" 4 5 func TestEnv(t *testing.T) { 6 name := "FOO" 7 expectedEnv := "PILADB_FOO" 8 9 if e := Env(name); e != expectedEnv { 10 t.Errorf("Env is %s, expected %s", e, expectedEnv) 11 } 12 } 13 14 func TestDefaultInt(t *testing.T) { 15 inputOutput := []struct { 16 input string 17 output int 18 }{ 19 {MaxStackSize, MaxStackSizeDefault}, 20 {ReadTimeout, ReadTimeoutDefault}, 21 {WriteTimeout, WriteTimeoutDefault}, 22 {ShutdownTimeout, ShutdownTimeoutDefault}, 23 {Port, PortDefault}, 24 {"foo", -1}, 25 } 26 27 for _, io := range inputOutput { 28 if o := DefaultInt(io.input); o != io.output { 29 t.Errorf("DefaultInt is %v, expected %v", o, io.output) 30 } 31 } 32 } 33 34 func TestDefaultBool(t *testing.T) { 35 inputOutput := []struct { 36 input string 37 output bool 38 }{ 39 {PushWhenFull, PushWhenFullDefault}, 40 {NoDonate, NoDonateDefault}, 41 {"foo", false}, 42 } 43 44 for _, io := range inputOutput { 45 if o := DefaultBool(io.input); o != io.output { 46 t.Errorf("DefaultBool is %v, expected %v", o, io.output) 47 } 48 } 49 }