aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/onsi/gomega/internal
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/onsi/gomega/internal')
-rw-r--r--vendor/github.com/onsi/gomega/internal/assertion/assertion.go98
-rw-r--r--vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion.go189
-rw-r--r--vendor/github.com/onsi/gomega/internal/oraclematcher/oracle_matcher.go25
-rw-r--r--vendor/github.com/onsi/gomega/internal/testingtsupport/testing_t_support.go40
4 files changed, 0 insertions, 352 deletions
diff --git a/vendor/github.com/onsi/gomega/internal/assertion/assertion.go b/vendor/github.com/onsi/gomega/internal/assertion/assertion.go
deleted file mode 100644
index b73673f..0000000
--- a/vendor/github.com/onsi/gomega/internal/assertion/assertion.go
+++ /dev/null
@@ -1,98 +0,0 @@
-package assertion
-
-import (
- "fmt"
- "reflect"
-
- "github.com/onsi/gomega/types"
-)
-
-type Assertion struct {
- actualInput interface{}
- fail types.GomegaFailHandler
- offset int
- extra []interface{}
-}
-
-func New(actualInput interface{}, fail types.GomegaFailHandler, offset int, extra ...interface{}) *Assertion {
- return &Assertion{
- actualInput: actualInput,
- fail: fail,
- offset: offset,
- extra: extra,
- }
-}
-
-func (assertion *Assertion) Should(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
- return assertion.vetExtras(optionalDescription...) && assertion.match(matcher, true, optionalDescription...)
-}
-
-func (assertion *Assertion) ShouldNot(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
- return assertion.vetExtras(optionalDescription...) && assertion.match(matcher, false, optionalDescription...)
-}
-
-func (assertion *Assertion) To(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
- return assertion.vetExtras(optionalDescription...) && assertion.match(matcher, true, optionalDescription...)
-}
-
-func (assertion *Assertion) ToNot(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
- return assertion.vetExtras(optionalDescription...) && assertion.match(matcher, false, optionalDescription...)
-}
-
-func (assertion *Assertion) NotTo(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
- return assertion.vetExtras(optionalDescription...) && assertion.match(matcher, false, optionalDescription...)
-}
-
-func (assertion *Assertion) buildDescription(optionalDescription ...interface{}) string {
- switch len(optionalDescription) {
- case 0:
- return ""
- default:
- return fmt.Sprintf(optionalDescription[0].(string), optionalDescription[1:]...) + "\n"
- }
-}
-
-func (assertion *Assertion) match(matcher types.GomegaMatcher, desiredMatch bool, optionalDescription ...interface{}) bool {
- matches, err := matcher.Match(assertion.actualInput)
- description := assertion.buildDescription(optionalDescription...)
- if err != nil {
- assertion.fail(description+err.Error(), 2+assertion.offset)
- return false
- }
- if matches != desiredMatch {
- var message string
- if desiredMatch {
- message = matcher.FailureMessage(assertion.actualInput)
- } else {
- message = matcher.NegatedFailureMessage(assertion.actualInput)
- }
- assertion.fail(description+message, 2+assertion.offset)
- return false
- }
-
- return true
-}
-
-func (assertion *Assertion) vetExtras(optionalDescription ...interface{}) bool {
- success, message := vetExtras(assertion.extra)
- if success {
- return true
- }
-
- description := assertion.buildDescription(optionalDescription...)
- assertion.fail(description+message, 2+assertion.offset)
- return false
-}
-
-func vetExtras(extras []interface{}) (bool, string) {
- for i, extra := range extras {
- if extra != nil {
- zeroValue := reflect.Zero(reflect.TypeOf(extra)).Interface()
- if !reflect.DeepEqual(zeroValue, extra) {
- message := fmt.Sprintf("Unexpected non-nil/non-zero extra argument at index %d:\n\t<%T>: %#v", i+1, extra, extra)
- return false, message
- }
- }
- }
- return true, ""
-}
diff --git a/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion.go b/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion.go
deleted file mode 100644
index bce0853..0000000
--- a/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion.go
+++ /dev/null
@@ -1,189 +0,0 @@
-package asyncassertion
-
-import (
- "errors"
- "fmt"
- "reflect"
- "time"
-
- "github.com/onsi/gomega/internal/oraclematcher"
- "github.com/onsi/gomega/types"
-)
-
-type AsyncAssertionType uint
-
-const (
- AsyncAssertionTypeEventually AsyncAssertionType = iota
- AsyncAssertionTypeConsistently
-)
-
-type AsyncAssertion struct {
- asyncType AsyncAssertionType
- actualInput interface{}
- timeoutInterval time.Duration
- pollingInterval time.Duration
- fail types.GomegaFailHandler
- offset int
-}
-
-func New(asyncType AsyncAssertionType, actualInput interface{}, fail types.GomegaFailHandler, timeoutInterval time.Duration, pollingInterval time.Duration, offset int) *AsyncAssertion {
- actualType := reflect.TypeOf(actualInput)
- if actualType.Kind() == reflect.Func {
- if actualType.NumIn() != 0 || actualType.NumOut() == 0 {
- panic("Expected a function with no arguments and one or more return values.")
- }
- }
-
- return &AsyncAssertion{
- asyncType: asyncType,
- actualInput: actualInput,
- fail: fail,
- timeoutInterval: timeoutInterval,
- pollingInterval: pollingInterval,
- offset: offset,
- }
-}
-
-func (assertion *AsyncAssertion) Should(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
- return assertion.match(matcher, true, optionalDescription...)
-}
-
-func (assertion *AsyncAssertion) ShouldNot(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
- return assertion.match(matcher, false, optionalDescription...)
-}
-
-func (assertion *AsyncAssertion) buildDescription(optionalDescription ...interface{}) string {
- switch len(optionalDescription) {
- case 0:
- return ""
- default:
- return fmt.Sprintf(optionalDescription[0].(string), optionalDescription[1:]...) + "\n"
- }
-}
-
-func (assertion *AsyncAssertion) actualInputIsAFunction() bool {
- actualType := reflect.TypeOf(assertion.actualInput)
- return actualType.Kind() == reflect.Func && actualType.NumIn() == 0 && actualType.NumOut() > 0
-}
-
-func (assertion *AsyncAssertion) pollActual() (interface{}, error) {
- if assertion.actualInputIsAFunction() {
- values := reflect.ValueOf(assertion.actualInput).Call([]reflect.Value{})
-
- extras := []interface{}{}
- for _, value := range values[1:] {
- extras = append(extras, value.Interface())
- }
-
- success, message := vetExtras(extras)
-
- if !success {
- return nil, errors.New(message)
- }
-
- return values[0].Interface(), nil
- }
-
- return assertion.actualInput, nil
-}
-
-func (assertion *AsyncAssertion) matcherMayChange(matcher types.GomegaMatcher, value interface{}) bool {
- if assertion.actualInputIsAFunction() {
- return true
- }
-
- return oraclematcher.MatchMayChangeInTheFuture(matcher, value)
-}
-
-func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch bool, optionalDescription ...interface{}) bool {
- timer := time.Now()
- timeout := time.After(assertion.timeoutInterval)
-
- description := assertion.buildDescription(optionalDescription...)
-
- var matches bool
- var err error
- mayChange := true
- value, err := assertion.pollActual()
- if err == nil {
- mayChange = assertion.matcherMayChange(matcher, value)
- matches, err = matcher.Match(value)
- }
-
- fail := func(preamble string) {
- errMsg := ""
- message := ""
- if err != nil {
- errMsg = "Error: " + err.Error()
- } else {
- if desiredMatch {
- message = matcher.FailureMessage(value)
- } else {
- message = matcher.NegatedFailureMessage(value)
- }
- }
- assertion.fail(fmt.Sprintf("%s after %.3fs.\n%s%s%s", preamble, time.Since(timer).Seconds(), description, message, errMsg), 3+assertion.offset)
- }
-
- if assertion.asyncType == AsyncAssertionTypeEventually {
- for {
- if err == nil && matches == desiredMatch {
- return true
- }
-
- if !mayChange {
- fail("No future change is possible. Bailing out early")
- return false
- }
-
- select {
- case <-time.After(assertion.pollingInterval):
- value, err = assertion.pollActual()
- if err == nil {
- mayChange = assertion.matcherMayChange(matcher, value)
- matches, err = matcher.Match(value)
- }
- case <-timeout:
- fail("Timed out")
- return false
- }
- }
- } else if assertion.asyncType == AsyncAssertionTypeConsistently {
- for {
- if !(err == nil && matches == desiredMatch) {
- fail("Failed")
- return false
- }
-
- if !mayChange {
- return true
- }
-
- select {
- case <-time.After(assertion.pollingInterval):
- value, err = assertion.pollActual()
- if err == nil {
- mayChange = assertion.matcherMayChange(matcher, value)
- matches, err = matcher.Match(value)
- }
- case <-timeout:
- return true
- }
- }
- }
-
- return false
-}
-
-func vetExtras(extras []interface{}) (bool, string) {
- for i, extra := range extras {
- if extra != nil {
- zeroValue := reflect.Zero(reflect.TypeOf(extra)).Interface()
- if !reflect.DeepEqual(zeroValue, extra) {
- message := fmt.Sprintf("Unexpected non-nil/non-zero extra argument at index %d:\n\t<%T>: %#v", i+1, extra, extra)
- return false, message
- }
- }
- }
- return true, ""
-}
diff --git a/vendor/github.com/onsi/gomega/internal/oraclematcher/oracle_matcher.go b/vendor/github.com/onsi/gomega/internal/oraclematcher/oracle_matcher.go
deleted file mode 100644
index 66cad88..0000000
--- a/vendor/github.com/onsi/gomega/internal/oraclematcher/oracle_matcher.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package oraclematcher
-
-import "github.com/onsi/gomega/types"
-
-/*
-GomegaMatchers that also match the OracleMatcher interface can convey information about
-whether or not their result will change upon future attempts.
-
-This allows `Eventually` and `Consistently` to short circuit if success becomes impossible.
-
-For example, a process' exit code can never change. So, gexec's Exit matcher returns `true`
-for `MatchMayChangeInTheFuture` until the process exits, at which point it returns `false` forevermore.
-*/
-type OracleMatcher interface {
- MatchMayChangeInTheFuture(actual interface{}) bool
-}
-
-func MatchMayChangeInTheFuture(matcher types.GomegaMatcher, value interface{}) bool {
- oracleMatcher, ok := matcher.(OracleMatcher)
- if !ok {
- return true
- }
-
- return oracleMatcher.MatchMayChangeInTheFuture(value)
-}
diff --git a/vendor/github.com/onsi/gomega/internal/testingtsupport/testing_t_support.go b/vendor/github.com/onsi/gomega/internal/testingtsupport/testing_t_support.go
deleted file mode 100644
index 7871fd4..0000000
--- a/vendor/github.com/onsi/gomega/internal/testingtsupport/testing_t_support.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package testingtsupport
-
-import (
- "regexp"
- "runtime/debug"
- "strings"
-
- "github.com/onsi/gomega/types"
-)
-
-type gomegaTestingT interface {
- Errorf(format string, args ...interface{})
-}
-
-func BuildTestingTGomegaFailHandler(t gomegaTestingT) types.GomegaFailHandler {
- return func(message string, callerSkip ...int) {
- skip := 1
- if len(callerSkip) > 0 {
- skip = callerSkip[0]
- }
- stackTrace := pruneStack(string(debug.Stack()), skip)
- t.Errorf("\n%s\n%s", stackTrace, message)
- }
-}
-
-func pruneStack(fullStackTrace string, skip int) string {
- stack := strings.Split(fullStackTrace, "\n")
- if len(stack) > 2*(skip+1) {
- stack = stack[2*(skip+1):]
- }
- prunedStack := []string{}
- re := regexp.MustCompile(`\/ginkgo\/|\/pkg\/testing\/|\/pkg\/runtime\/`)
- for i := 0; i < len(stack)/2; i++ {
- if !re.Match([]byte(stack[i*2])) {
- prunedStack = append(prunedStack, stack[i*2])
- prunedStack = append(prunedStack, stack[i*2+1])
- }
- }
- return strings.Join(prunedStack, "\n")
-}