mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
f2614f2107
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
46 lines
882 B
Go
46 lines
882 B
Go
package shakers
|
|
|
|
import (
|
|
"github.com/go-check/check"
|
|
)
|
|
|
|
// True checker verifies the obtained value is true
|
|
//
|
|
// c.Assert(myBool, True)
|
|
//
|
|
var True check.Checker = &boolChecker{
|
|
&check.CheckerInfo{
|
|
Name: "True",
|
|
Params: []string{"obtained"},
|
|
},
|
|
true,
|
|
}
|
|
|
|
// False checker verifies the obtained value is false
|
|
//
|
|
// c.Assert(myBool, False)
|
|
//
|
|
var False check.Checker = &boolChecker{
|
|
&check.CheckerInfo{
|
|
Name: "False",
|
|
Params: []string{"obtained"},
|
|
},
|
|
false,
|
|
}
|
|
|
|
type boolChecker struct {
|
|
*check.CheckerInfo
|
|
expected bool
|
|
}
|
|
|
|
func (checker *boolChecker) Check(params []interface{}, names []string) (bool, string) {
|
|
return is(checker.expected, params[0])
|
|
}
|
|
|
|
func is(expected bool, obtained interface{}) (bool, string) {
|
|
obtainedBool, ok := obtained.(bool)
|
|
if !ok {
|
|
return false, "obtained value must be a bool."
|
|
}
|
|
return obtainedBool == expected, ""
|
|
}
|