1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-08-06 19:44:01 +08:00
Files
kubo/commands/option_test.go
Jeromy 767ee13ea2 add default option value support to commands lib
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2016-03-04 10:58:27 -08:00

30 lines
740 B
Go

package commands
import "testing"
func TestOptionValueExtractBoolNotFound(t *testing.T) {
t.Log("ensure that no error is returned when value is not found")
optval := &OptionValue{found: false}
_, _, err := optval.Bool()
if err != nil {
t.Fatal("Found was false. Err should have been nil")
}
}
func TestOptionValueExtractWrongType(t *testing.T) {
t.Log("ensure that error is returned when value if of wrong type")
optval := &OptionValue{value: "wrong type: a string", found: true}
_, _, err := optval.Bool()
if err == nil {
t.Fatal("No error returned. Failure.")
}
optval = &OptionValue{value: "wrong type: a string", found: true}
_, _, err = optval.Int()
if err == nil {
t.Fatal("No error returned. Failure.")
}
}