mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-06-10 10:15:57 +00:00
Switch to ginkgo/gomega for tests
This switches over to ginkgo/gomega for tests, which makes writing certain tests easier/more fluent in the future.
This commit is contained in:
parent
c5801455ec
commit
cc08a1fb41
260 changed files with 184637 additions and 6412 deletions
38
vendor/github.com/onsi/gomega/matchers/contain_substring_matcher.go
generated
vendored
Normal file
38
vendor/github.com/onsi/gomega/matchers/contain_substring_matcher.go
generated
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package matchers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/onsi/gomega/format"
|
||||
)
|
||||
|
||||
type ContainSubstringMatcher struct {
|
||||
Substr string
|
||||
Args []interface{}
|
||||
}
|
||||
|
||||
func (matcher *ContainSubstringMatcher) Match(actual interface{}) (success bool, err error) {
|
||||
actualString, ok := toString(actual)
|
||||
if !ok {
|
||||
return false, fmt.Errorf("ContainSubstring matcher requires a string or stringer. Got:\n%s", format.Object(actual, 1))
|
||||
}
|
||||
|
||||
return strings.Contains(actualString, matcher.stringToMatch()), nil
|
||||
}
|
||||
|
||||
func (matcher *ContainSubstringMatcher) stringToMatch() string {
|
||||
stringToMatch := matcher.Substr
|
||||
if len(matcher.Args) > 0 {
|
||||
stringToMatch = fmt.Sprintf(matcher.Substr, matcher.Args...)
|
||||
}
|
||||
return stringToMatch
|
||||
}
|
||||
|
||||
func (matcher *ContainSubstringMatcher) FailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, "to contain substring", matcher.stringToMatch())
|
||||
}
|
||||
|
||||
func (matcher *ContainSubstringMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, "not to contain substring", matcher.stringToMatch())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue