mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 09:41:57 +00:00
Upgraded from 99c19923, branch release-3.0. This required fetching or upgrading the following: * k8s.io/api to kubernetes-1.9.1 * k8s.io/apimachinery to kubernetes-1.9.1 * github.com/juju/ratelimit to 1.0.1 * github.com/spf13/pflag to 4c012f6d Also, update Scope's imports/function calls to be compatible with the new client.
38 lines
988 B
Go
38 lines
988 B
Go
package matchers
|
|
|
|
import (
|
|
"fmt"
|
|
"runtime"
|
|
|
|
"github.com/onsi/gomega/format"
|
|
)
|
|
|
|
type BeIdenticalToMatcher struct {
|
|
Expected interface{}
|
|
}
|
|
|
|
func (matcher *BeIdenticalToMatcher) Match(actual interface{}) (success bool, matchErr error) {
|
|
if actual == nil && matcher.Expected == nil {
|
|
return false, fmt.Errorf("Refusing to compare <nil> to <nil>.\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.")
|
|
}
|
|
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
if _, ok := r.(runtime.Error); ok {
|
|
success = false
|
|
matchErr = nil
|
|
}
|
|
}
|
|
}()
|
|
|
|
return actual == matcher.Expected, nil
|
|
}
|
|
|
|
func (matcher *BeIdenticalToMatcher) FailureMessage(actual interface{}) string {
|
|
return format.Message(actual, "to be identical to", matcher.Expected)
|
|
}
|
|
|
|
func (matcher *BeIdenticalToMatcher) NegatedFailureMessage(actual interface{}) string {
|
|
return format.Message(actual, "not to be identical to", matcher.Expected)
|
|
}
|