"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "vendor/github.com/onsi/gomega/gomega_dsl.go" between
buildah-1.10.1.tar.gz and buildah-1.11.0.tar.gz

About: Buildah is a tool that facilitates building Open Container Initiative (OCI) container images.

gomega_dsl.go  (buildah-1.10.1):gomega_dsl.go  (buildah-1.11.0)
skipping to change at line 27 skipping to change at line 27
"fmt" "fmt"
"reflect" "reflect"
"time" "time"
"github.com/onsi/gomega/internal/assertion" "github.com/onsi/gomega/internal/assertion"
"github.com/onsi/gomega/internal/asyncassertion" "github.com/onsi/gomega/internal/asyncassertion"
"github.com/onsi/gomega/internal/testingtsupport" "github.com/onsi/gomega/internal/testingtsupport"
"github.com/onsi/gomega/types" "github.com/onsi/gomega/types"
) )
const GOMEGA_VERSION = "1.4.3" const GOMEGA_VERSION = "1.5.0"
const nilFailHandlerPanic = `You are trying to make an assertion, but Gomega's f ail handler is nil. const nilFailHandlerPanic = `You are trying to make an assertion, but Gomega's f ail handler is nil.
If you're using Ginkgo then you probably forgot to put your assertion in an It() . If you're using Ginkgo then you probably forgot to put your assertion in an It() .
Alternatively, you may have forgotten to register a fail handler with RegisterFa ilHandler() or RegisterTestingT(). Alternatively, you may have forgotten to register a fail handler with RegisterFa ilHandler() or RegisterTestingT().
Depending on your vendoring solution you may be inadvertently importing gomega a nd subpackages (e.g. ghhtp, gexec,...) from different locations. Depending on your vendoring solution you may be inadvertently importing gomega a nd subpackages (e.g. ghhtp, gexec,...) from different locations.
` `
var globalFailWrapper *types.GomegaFailWrapper var globalFailWrapper *types.GomegaFailWrapper
var defaultEventuallyTimeout = time.Second var defaultEventuallyTimeout = time.Second
var defaultEventuallyPollingInterval = 10 * time.Millisecond var defaultEventuallyPollingInterval = 10 * time.Millisecond
var defaultConsistentlyDuration = 100 * time.Millisecond var defaultConsistentlyDuration = 100 * time.Millisecond
var defaultConsistentlyPollingInterval = 10 * time.Millisecond var defaultConsistentlyPollingInterval = 10 * time.Millisecond
//RegisterFailHandler connects Ginkgo to Gomega. When a matcher fails // RegisterFailHandler connects Ginkgo to Gomega. When a matcher fails
//the fail handler passed into RegisterFailHandler is called. // the fail handler passed into RegisterFailHandler is called.
func RegisterFailHandler(handler types.GomegaFailHandler) { func RegisterFailHandler(handler types.GomegaFailHandler) {
if handler == nil { RegisterFailHandlerWithT(testingtsupport.EmptyTWithHelper{}, handler)
globalFailWrapper = nil
return
}
globalFailWrapper = &types.GomegaFailWrapper{
Fail: handler,
TWithHelper: testingtsupport.EmptyTWithHelper{},
}
} }
// RegisterFailHandlerWithT ensures that the given types.TWithHelper and fail ha
ndler
// are used globally.
func RegisterFailHandlerWithT(t types.TWithHelper, handler types.GomegaFailHandl er) { func RegisterFailHandlerWithT(t types.TWithHelper, handler types.GomegaFailHandl er) {
if handler == nil { if handler == nil {
globalFailWrapper = nil globalFailWrapper = nil
return return
} }
globalFailWrapper = &types.GomegaFailWrapper{ globalFailWrapper = &types.GomegaFailWrapper{
Fail: handler, Fail: handler,
TWithHelper: t, TWithHelper: t,
} }
} }
//RegisterTestingT connects Gomega to Golang's XUnit style // RegisterTestingT connects Gomega to Golang's XUnit style
//Testing.T tests. It is now deprecated and you should use NewGomegaWithT() ins // Testing.T tests. It is now deprecated and you should use NewWithT() instead.
tead.
// //
//Legacy Documentation: // Legacy Documentation:
// //
//You'll need to call this at the top of each XUnit style test: // You'll need to call this at the top of each XUnit style test:
// //
// func TestFarmHasCow(t *testing.T) { // func TestFarmHasCow(t *testing.T) {
// RegisterTestingT(t) // RegisterTestingT(t)
// //
// f := farm.New([]string{"Cow", "Horse"}) // f := farm.New([]string{"Cow", "Horse"})
// Expect(f.HasCow()).To(BeTrue(), "Farm should have cow") // Expect(f.HasCow()).To(BeTrue(), "Farm should have cow")
// } // }
// //
// Note that this *testing.T is registered *globally* by Gomega (this is why you don't have to // Note that this *testing.T is registered *globally* by Gomega (this is why you don't have to
// pass `t` down to the matcher itself). This means that you cannot run the XUn it style tests // pass `t` down to the matcher itself). This means that you cannot run the XUn it style tests
// in parallel as the global fail handler cannot point to more than one testing. T at a time. // in parallel as the global fail handler cannot point to more than one testing. T at a time.
// //
// NewGomegaWithT() does not have this limitation // NewWithT() does not have this limitation
// //
// (As an aside: Ginkgo gets around this limitation by running parallel tests in different *processes*). // (As an aside: Ginkgo gets around this limitation by running parallel tests in different *processes*).
func RegisterTestingT(t types.GomegaTestingT) { func RegisterTestingT(t types.GomegaTestingT) {
tWithHelper, hasHelper := t.(types.TWithHelper) tWithHelper, hasHelper := t.(types.TWithHelper)
if !hasHelper { if !hasHelper {
RegisterFailHandler(testingtsupport.BuildTestingTGomegaFailWrappe r(t).Fail) RegisterFailHandler(testingtsupport.BuildTestingTGomegaFailWrappe r(t).Fail)
return return
} }
RegisterFailHandlerWithT(tWithHelper, testingtsupport.BuildTestingTGomega FailWrapper(t).Fail) RegisterFailHandlerWithT(tWithHelper, testingtsupport.BuildTestingTGomega FailWrapper(t).Fail)
} }
//InterceptGomegaHandlers runs a given callback and returns an array of // InterceptGomegaFailures runs a given callback and returns an array of
//failure messages generated by any Gomega assertions within the callback. // failure messages generated by any Gomega assertions within the callback.
// //
//This is accomplished by temporarily replacing the *global* fail handler // This is accomplished by temporarily replacing the *global* fail handler
//with a fail handler that simply annotates failures. The original fail handler // with a fail handler that simply annotates failures. The original fail handle
//is reset when InterceptGomegaFailures returns. r
// is reset when InterceptGomegaFailures returns.
// //
//This is most useful when testing custom matchers, but can also be used to chec // This is most useful when testing custom matchers, but can also be used to che
k ck
//on a value using a Gomega assertion without causing a test failure. // on a value using a Gomega assertion without causing a test failure.
func InterceptGomegaFailures(f func()) []string { func InterceptGomegaFailures(f func()) []string {
originalHandler := globalFailWrapper.Fail originalHandler := globalFailWrapper.Fail
failures := []string{} failures := []string{}
RegisterFailHandler(func(message string, callerSkip ...int) { RegisterFailHandler(func(message string, callerSkip ...int) {
failures = append(failures, message) failures = append(failures, message)
}) })
f() f()
RegisterFailHandler(originalHandler) RegisterFailHandler(originalHandler)
return failures return failures
} }
//Ω wraps an actual value allowing assertions to be made on it: // Ω wraps an actual value allowing assertions to be made on it:
// Ω("foo").Should(Equal("foo")) // Ω("foo").Should(Equal("foo"))
// //
//If Ω is passed more than one argument it will pass the *first* argument to the // If Ω is passed more than one argument it will pass the *first* argument to th
matcher. e matcher.
//All subsequent arguments will be required to be nil/zero. // All subsequent arguments will be required to be nil/zero.
// //
//This is convenient if you want to make an assertion on a method/function that // This is convenient if you want to make an assertion on a method/function that
returns returns
//a value and an error - a common patter in Go. // a value and an error - a common patter in Go.
// //
//For example, given a function with signature: // For example, given a function with signature:
// func MyAmazingThing() (int, error) // func MyAmazingThing() (int, error)
// //
//Then: // Then:
// Ω(MyAmazingThing()).Should(Equal(3)) // Ω(MyAmazingThing()).Should(Equal(3))
//Will succeed only if `MyAmazingThing()` returns `(3, nil)` // Will succeed only if `MyAmazingThing()` returns `(3, nil)`
// //
//Ω and Expect are identical // Ω and Expect are identical
func Ω(actual interface{}, extra ...interface{}) GomegaAssertion { func Ω(actual interface{}, extra ...interface{}) Assertion {
return ExpectWithOffset(0, actual, extra...) return ExpectWithOffset(0, actual, extra...)
} }
//Expect wraps an actual value allowing assertions to be made on it: // Expect wraps an actual value allowing assertions to be made on it:
// Expect("foo").To(Equal("foo")) // Expect("foo").To(Equal("foo"))
// //
//If Expect is passed more than one argument it will pass the *first* argument t // If Expect is passed more than one argument it will pass the *first* argument
o the matcher. to the matcher.
//All subsequent arguments will be required to be nil/zero. // All subsequent arguments will be required to be nil/zero.
// //
//This is convenient if you want to make an assertion on a method/function that // This is convenient if you want to make an assertion on a method/function that
returns returns
//a value and an error - a common patter in Go. // a value and an error - a common patter in Go.
// //
//For example, given a function with signature: // For example, given a function with signature:
// func MyAmazingThing() (int, error) // func MyAmazingThing() (int, error)
// //
//Then: // Then:
// Expect(MyAmazingThing()).Should(Equal(3)) // Expect(MyAmazingThing()).Should(Equal(3))
//Will succeed only if `MyAmazingThing()` returns `(3, nil)` // Will succeed only if `MyAmazingThing()` returns `(3, nil)`
// //
//Expect and Ω are identical // Expect and Ω are identical
func Expect(actual interface{}, extra ...interface{}) GomegaAssertion { func Expect(actual interface{}, extra ...interface{}) Assertion {
return ExpectWithOffset(0, actual, extra...) return ExpectWithOffset(0, actual, extra...)
} }
//ExpectWithOffset wraps an actual value allowing assertions to be made on it: // ExpectWithOffset wraps an actual value allowing assertions to be made on it:
// ExpectWithOffset(1, "foo").To(Equal("foo")) // ExpectWithOffset(1, "foo").To(Equal("foo"))
// //
//Unlike `Expect` and `Ω`, `ExpectWithOffset` takes an additional integer argume // Unlike `Expect` and `Ω`, `ExpectWithOffset` takes an additional integer argum
nt ent
//this is used to modify the call-stack offset when computing line numbers. // this is used to modify the call-stack offset when computing line numbers.
// //
//This is most useful in helper functions that make assertions. If you want Gom // This is most useful in helper functions that make assertions. If you want Go
ega's mega's
//error message to refer to the calling line in the test (as opposed to the line // error message to refer to the calling line in the test (as opposed to the lin
in the helper function) e in the helper function)
//set the first argument of `ExpectWithOffset` appropriately. // set the first argument of `ExpectWithOffset` appropriately.
func ExpectWithOffset(offset int, actual interface{}, extra ...interface{}) Gome func ExpectWithOffset(offset int, actual interface{}, extra ...interface{}) Asse
gaAssertion { rtion {
if globalFailWrapper == nil { if globalFailWrapper == nil {
panic(nilFailHandlerPanic) panic(nilFailHandlerPanic)
} }
return assertion.New(actual, globalFailWrapper, offset, extra...) return assertion.New(actual, globalFailWrapper, offset, extra...)
} }
//Eventually wraps an actual value allowing assertions to be made on it. // Eventually wraps an actual value allowing assertions to be made on it.
//The assertion is tried periodically until it passes or a timeout occurs. // The assertion is tried periodically until it passes or a timeout occurs.
// //
//Both the timeout and polling interval are configurable as optional arguments: // Both the timeout and polling interval are configurable as optional arguments:
//The first optional argument is the timeout // The first optional argument is the timeout
//The second optional argument is the polling interval // The second optional argument is the polling interval
// //
//Both intervals can either be specified as time.Duration, parsable duration str // Both intervals can either be specified as time.Duration, parsable duration st
ings or as floats/integers. In the rings or as floats/integers. In the
//last case they are interpreted as seconds. // last case they are interpreted as seconds.
// //
//If Eventually is passed an actual that is a function taking no arguments and r // If Eventually is passed an actual that is a function taking no arguments and
eturning at least one value, returning at least one value,
//then Eventually will call the function periodically and try the matcher agains // then Eventually will call the function periodically and try the matcher again
t the function's first return value. st the function's first return value.
// //
//Example: // Example:
// //
// Eventually(func() int { // Eventually(func() int {
// return thingImPolling.Count() // return thingImPolling.Count()
// }).Should(BeNumerically(">=", 17)) // }).Should(BeNumerically(">=", 17))
// //
//Note that this example could be rewritten: // Note that this example could be rewritten:
// //
// Eventually(thingImPolling.Count).Should(BeNumerically(">=", 17)) // Eventually(thingImPolling.Count).Should(BeNumerically(">=", 17))
// //
//If the function returns more than one value, then Eventually will pass the fir // If the function returns more than one value, then Eventually will pass the fi
st value to the matcher and rst value to the matcher and
//assert that all other values are nil/zero. // assert that all other values are nil/zero.
//This allows you to pass Eventually a function that returns a value and an erro // This allows you to pass Eventually a function that returns a value and an err
r - a common pattern in Go. or - a common pattern in Go.
// //
//For example, consider a method that returns a value and an error: // For example, consider a method that returns a value and an error:
// func FetchFromDB() (string, error) // func FetchFromDB() (string, error)
// //
//Then // Then
// Eventually(FetchFromDB).Should(Equal("hasselhoff")) // Eventually(FetchFromDB).Should(Equal("hasselhoff"))
// //
//Will pass only if the the returned error is nil and the returned string passes the matcher. // Will pass only if the the returned error is nil and the returned string passe s the matcher.
// //
//Eventually's default timeout is 1 second, and its default polling interval is // Eventually's default timeout is 1 second, and its default polling interval is
10ms 10ms
func Eventually(actual interface{}, intervals ...interface{}) GomegaAsyncAsserti func Eventually(actual interface{}, intervals ...interface{}) AsyncAssertion {
on {
return EventuallyWithOffset(0, actual, intervals...) return EventuallyWithOffset(0, actual, intervals...)
} }
//EventuallyWithOffset operates like Eventually but takes an additional // EventuallyWithOffset operates like Eventually but takes an additional
//initial argument to indicate an offset in the call stack. This is useful when // initial argument to indicate an offset in the call stack. This is useful whe
building helper n building helper
//functions that contain matchers. To learn more, read about `ExpectWithOffset` // functions that contain matchers. To learn more, read about `ExpectWithOffset
. `.
func EventuallyWithOffset(offset int, actual interface{}, intervals ...interface func EventuallyWithOffset(offset int, actual interface{}, intervals ...interface
{}) GomegaAsyncAssertion { {}) AsyncAssertion {
if globalFailWrapper == nil { if globalFailWrapper == nil {
panic(nilFailHandlerPanic) panic(nilFailHandlerPanic)
} }
timeoutInterval := defaultEventuallyTimeout timeoutInterval := defaultEventuallyTimeout
pollingInterval := defaultEventuallyPollingInterval pollingInterval := defaultEventuallyPollingInterval
if len(intervals) > 0 { if len(intervals) > 0 {
timeoutInterval = toDuration(intervals[0]) timeoutInterval = toDuration(intervals[0])
} }
if len(intervals) > 1 { if len(intervals) > 1 {
pollingInterval = toDuration(intervals[1]) pollingInterval = toDuration(intervals[1])
} }
return asyncassertion.New(asyncassertion.AsyncAssertionTypeEventually, ac tual, globalFailWrapper, timeoutInterval, pollingInterval, offset) return asyncassertion.New(asyncassertion.AsyncAssertionTypeEventually, ac tual, globalFailWrapper, timeoutInterval, pollingInterval, offset)
} }
//Consistently wraps an actual value allowing assertions to be made on it. // Consistently wraps an actual value allowing assertions to be made on it.
//The assertion is tried periodically and is required to pass for a period of ti // The assertion is tried periodically and is required to pass for a period of t
me. ime.
// //
//Both the total time and polling interval are configurable as optional argument // Both the total time and polling interval are configurable as optional argumen
s: ts:
//The first optional argument is the duration that Consistently will run for // The first optional argument is the duration that Consistently will run for
//The second optional argument is the polling interval // The second optional argument is the polling interval
// //
//Both intervals can either be specified as time.Duration, parsable duration str // Both intervals can either be specified as time.Duration, parsable duration st
ings or as floats/integers. In the rings or as floats/integers. In the
//last case they are interpreted as seconds. // last case they are interpreted as seconds.
// //
//If Consistently is passed an actual that is a function taking no arguments and // If Consistently is passed an actual that is a function taking no arguments an
returning at least one value, d returning at least one value,
//then Consistently will call the function periodically and try the matcher agai // then Consistently will call the function periodically and try the matcher aga
nst the function's first return value. inst the function's first return value.
// //
//If the function returns more than one value, then Consistently will pass the f // If the function returns more than one value, then Consistently will pass the
irst value to the matcher and first value to the matcher and
//assert that all other values are nil/zero. // assert that all other values are nil/zero.
//This allows you to pass Consistently a function that returns a value and an er // This allows you to pass Consistently a function that returns a value and an e
ror - a common pattern in Go. rror - a common pattern in Go.
// //
//Consistently is useful in cases where you want to assert that something *does // Consistently is useful in cases where you want to assert that something *does
not happen* over a period of tiem. not happen* over a period of tiem.
//For example, you want to assert that a goroutine does *not* send data down a c // For example, you want to assert that a goroutine does *not* send data down a
hannel. In this case, you could: channel. In this case, you could:
// //
// Consistently(channel).ShouldNot(Receive()) // Consistently(channel).ShouldNot(Receive())
// //
//Consistently's default duration is 100ms, and its default polling interval is // Consistently's default duration is 100ms, and its default polling interval is
10ms 10ms
func Consistently(actual interface{}, intervals ...interface{}) GomegaAsyncAsser func Consistently(actual interface{}, intervals ...interface{}) AsyncAssertion {
tion {
return ConsistentlyWithOffset(0, actual, intervals...) return ConsistentlyWithOffset(0, actual, intervals...)
} }
//ConsistentlyWithOffset operates like Consistnetly but takes an additional // ConsistentlyWithOffset operates like Consistnetly but takes an additional
//initial argument to indicate an offset in the call stack. This is useful when // initial argument to indicate an offset in the call stack. This is useful when
building helper building helper
//functions that contain matchers. To learn more, read about `ExpectWithOffset` // functions that contain matchers. To learn more, read about `ExpectWithOffset`
. .
func ConsistentlyWithOffset(offset int, actual interface{}, intervals ...interfa func ConsistentlyWithOffset(offset int, actual interface{}, intervals ...interfa
ce{}) GomegaAsyncAssertion { ce{}) AsyncAssertion {
if globalFailWrapper == nil { if globalFailWrapper == nil {
panic(nilFailHandlerPanic) panic(nilFailHandlerPanic)
} }
timeoutInterval := defaultConsistentlyDuration timeoutInterval := defaultConsistentlyDuration
pollingInterval := defaultConsistentlyPollingInterval pollingInterval := defaultConsistentlyPollingInterval
if len(intervals) > 0 { if len(intervals) > 0 {
timeoutInterval = toDuration(intervals[0]) timeoutInterval = toDuration(intervals[0])
} }
if len(intervals) > 1 { if len(intervals) > 1 {
pollingInterval = toDuration(intervals[1]) pollingInterval = toDuration(intervals[1])
} }
return asyncassertion.New(asyncassertion.AsyncAssertionTypeConsistently, actual, globalFailWrapper, timeoutInterval, pollingInterval, offset) return asyncassertion.New(asyncassertion.AsyncAssertionTypeConsistently, actual, globalFailWrapper, timeoutInterval, pollingInterval, offset)
} }
//Set the default timeout duration for Eventually. Eventually will repeatedly p oll your condition until it succeeds, or until this timeout elapses. // SetDefaultEventuallyTimeout sets the default timeout duration for Eventually. Eventually will repeatedly poll your condition until it succeeds, or until this timeout elapses.
func SetDefaultEventuallyTimeout(t time.Duration) { func SetDefaultEventuallyTimeout(t time.Duration) {
defaultEventuallyTimeout = t defaultEventuallyTimeout = t
} }
//Set the default polling interval for Eventually. // SetDefaultEventuallyPollingInterval sets the default polling interval for Eve ntually.
func SetDefaultEventuallyPollingInterval(t time.Duration) { func SetDefaultEventuallyPollingInterval(t time.Duration) {
defaultEventuallyPollingInterval = t defaultEventuallyPollingInterval = t
} }
//Set the default duration for Consistently. Consistently will verify that your condition is satsified for this long. // SetDefaultConsistentlyDuration sets the default duration for Consistently. C onsistently will verify that your condition is satsified for this long.
func SetDefaultConsistentlyDuration(t time.Duration) { func SetDefaultConsistentlyDuration(t time.Duration) {
defaultConsistentlyDuration = t defaultConsistentlyDuration = t
} }
//Set the default polling interval for Consistently. // SetDefaultConsistentlyPollingInterval sets the default polling interval for C onsistently.
func SetDefaultConsistentlyPollingInterval(t time.Duration) { func SetDefaultConsistentlyPollingInterval(t time.Duration) {
defaultConsistentlyPollingInterval = t defaultConsistentlyPollingInterval = t
} }
//GomegaAsyncAssertion is returned by Eventually and Consistently and polls the // AsyncAssertion is returned by Eventually and Consistently and polls the actua
actual value passed into Eventually against l value passed into Eventually against
//the matcher passed to the Should and ShouldNot methods. // the matcher passed to the Should and ShouldNot methods.
// //
//Both Should and ShouldNot take a variadic optionalDescription argument. This // Both Should and ShouldNot take a variadic optionalDescription argument. This
is passed on to is passed on to
//fmt.Sprintf() and is used to annotate failure messages. This allows you to ma // fmt.Sprintf() and is used to annotate failure messages. This allows you to m
ke your failure messages more ake your failure messages more
//descriptive // descriptive.
// //
//Both Should and ShouldNot return a boolean that is true if the assertion passe d and false if it failed. // Both Should and ShouldNot return a boolean that is true if the assertion pass ed and false if it failed.
// //
//Example: // Example:
// //
// Eventually(myChannel).Should(Receive(), "Something should have come down the // Eventually(myChannel).Should(Receive(), "Something should have come down th
pipe.") e pipe.")
// Consistently(myChannel).ShouldNot(Receive(), "Nothing should have come down // Consistently(myChannel).ShouldNot(Receive(), "Nothing should have come down
the pipe.") the pipe.")
type GomegaAsyncAssertion interface { type AsyncAssertion interface {
Should(matcher types.GomegaMatcher, optionalDescription ...interface{}) b ool Should(matcher types.GomegaMatcher, optionalDescription ...interface{}) b ool
ShouldNot(matcher types.GomegaMatcher, optionalDescription ...interface{} ) bool ShouldNot(matcher types.GomegaMatcher, optionalDescription ...interface{} ) bool
} }
//GomegaAssertion is returned by Ω and Expect and compares the actual value to t // GomegaAsyncAssertion is deprecated in favor of AsyncAssertion, which does not
he matcher stutter.
//passed to the Should/ShouldNot and To/ToNot/NotTo methods. type GomegaAsyncAssertion = AsyncAssertion
// Assertion is returned by Ω and Expect and compares the actual value to the ma
tcher
// passed to the Should/ShouldNot and To/ToNot/NotTo methods.
// //
//Typically Should/ShouldNot are used with Ω and To/ToNot/NotTo are used with Ex // Typically Should/ShouldNot are used with Ω and To/ToNot/NotTo are used with E
pect xpect
//though this is not enforced. // though this is not enforced.
// //
//All methods take a variadic optionalDescription argument. This is passed on t // All methods take a variadic optionalDescription argument. This is passed on
o fmt.Sprintf() to fmt.Sprintf()
//and is used to annotate failure messages. // and is used to annotate failure messages.
// //
//All methods return a bool that is true if hte assertion passed and false if it failed. // All methods return a bool that is true if hte assertion passed and false if i t failed.
// //
//Example: // Example:
// //
// Ω(farm.HasCow()).Should(BeTrue(), "Farm %v should have a cow", farm) // Ω(farm.HasCow()).Should(BeTrue(), "Farm %v should have a cow", farm)
type GomegaAssertion interface { type Assertion interface {
Should(matcher types.GomegaMatcher, optionalDescription ...interface{}) b ool Should(matcher types.GomegaMatcher, optionalDescription ...interface{}) b ool
ShouldNot(matcher types.GomegaMatcher, optionalDescription ...interface{} ) bool ShouldNot(matcher types.GomegaMatcher, optionalDescription ...interface{} ) bool
To(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool To(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool
ToNot(matcher types.GomegaMatcher, optionalDescription ...interface{}) bo ol ToNot(matcher types.GomegaMatcher, optionalDescription ...interface{}) bo ol
NotTo(matcher types.GomegaMatcher, optionalDescription ...interface{}) bo ol NotTo(matcher types.GomegaMatcher, optionalDescription ...interface{}) bo ol
} }
//OmegaMatcher is deprecated in favor of the better-named and better-organized t // GomegaAssertion is deprecated in favor of Assertion, which does not stutter.
ypes.GomegaMatcher but sticks around to support existing code that uses it type GomegaAssertion = Assertion
// OmegaMatcher is deprecated in favor of the better-named and better-organized
types.GomegaMatcher but sticks around to support existing code that uses it
type OmegaMatcher types.GomegaMatcher type OmegaMatcher types.GomegaMatcher
//GomegaWithT wraps a *testing.T and provides `Expect`, `Eventually`, and `Consi // WithT wraps a *testing.T and provides `Expect`, `Eventually`, and `Consistent
stently` methods. This allows you to leverage ly` methods. This allows you to leverage
//Gomega's rich ecosystem of matchers in standard `testing` test suites. // Gomega's rich ecosystem of matchers in standard `testing` test suites.
// //
//Use `NewGomegaWithT` to instantiate a `GomegaWithT` // Use `NewWithT` to instantiate a `WithT`
type GomegaWithT struct { type WithT struct {
t types.GomegaTestingT t types.GomegaTestingT
} }
//NewGomegaWithT takes a *testing.T and returngs a `GomegaWithT` allowing you to // GomegaWithT is deprecated in favor of gomega.WithT, which does not stutter.
use `Expect`, `Eventually`, and `Consistently` along with type GomegaWithT = WithT
//Gomega's rich ecosystem of matchers in standard `testing` test suits.
// NewWithT takes a *testing.T and returngs a `gomega.WithT` allowing you to use
`Expect`, `Eventually`, and `Consistently` along with
// Gomega's rich ecosystem of matchers in standard `testing` test suits.
// //
// func TestFarmHasCow(t *testing.T) { // func TestFarmHasCow(t *testing.T) {
// g := GomegaWithT(t) // g := gomega.NewWithT(t)
// //
// f := farm.New([]string{"Cow", "Horse"}) // f := farm.New([]string{"Cow", "Horse"})
// g.Expect(f.HasCow()).To(BeTrue(), "Farm should have cow") // g.Expect(f.HasCow()).To(BeTrue(), "Farm should have cow")
// } // }
func NewGomegaWithT(t types.GomegaTestingT) *GomegaWithT { func NewWithT(t types.GomegaTestingT) *WithT {
return &GomegaWithT{ return &WithT{
t: t, t: t,
} }
} }
//See documentation for Expect // NewGomegaWithT is deprecated in favor of gomega.NewWithT, which does not stut
func (g *GomegaWithT) Expect(actual interface{}, extra ...interface{}) GomegaAss ter.
ertion { func NewGomegaWithT(t types.GomegaTestingT) *GomegaWithT {
return NewWithT(t)
}
// Expect is used to make assertions. See documentation for Expect.
func (g *WithT) Expect(actual interface{}, extra ...interface{}) Assertion {
return assertion.New(actual, testingtsupport.BuildTestingTGomegaFailWrapp er(g.t), 0, extra...) return assertion.New(actual, testingtsupport.BuildTestingTGomegaFailWrapp er(g.t), 0, extra...)
} }
//See documentation for Eventually // Eventually is used to make asynchronous assertions. See documentation for Eve
func (g *GomegaWithT) Eventually(actual interface{}, intervals ...interface{}) G ntually.
omegaAsyncAssertion { func (g *WithT) Eventually(actual interface{}, intervals ...interface{}) AsyncAs
sertion {
timeoutInterval := defaultEventuallyTimeout timeoutInterval := defaultEventuallyTimeout
pollingInterval := defaultEventuallyPollingInterval pollingInterval := defaultEventuallyPollingInterval
if len(intervals) > 0 { if len(intervals) > 0 {
timeoutInterval = toDuration(intervals[0]) timeoutInterval = toDuration(intervals[0])
} }
if len(intervals) > 1 { if len(intervals) > 1 {
pollingInterval = toDuration(intervals[1]) pollingInterval = toDuration(intervals[1])
} }
return asyncassertion.New(asyncassertion.AsyncAssertionTypeEventually, ac tual, testingtsupport.BuildTestingTGomegaFailWrapper(g.t), timeoutInterval, poll ingInterval, 0) return asyncassertion.New(asyncassertion.AsyncAssertionTypeEventually, ac tual, testingtsupport.BuildTestingTGomegaFailWrapper(g.t), timeoutInterval, poll ingInterval, 0)
} }
//See documentation for Consistently // Consistently is used to make asynchronous assertions. See documentation for C
func (g *GomegaWithT) Consistently(actual interface{}, intervals ...interface{}) onsistently.
GomegaAsyncAssertion { func (g *WithT) Consistently(actual interface{}, intervals ...interface{}) Async
Assertion {
timeoutInterval := defaultConsistentlyDuration timeoutInterval := defaultConsistentlyDuration
pollingInterval := defaultConsistentlyPollingInterval pollingInterval := defaultConsistentlyPollingInterval
if len(intervals) > 0 { if len(intervals) > 0 {
timeoutInterval = toDuration(intervals[0]) timeoutInterval = toDuration(intervals[0])
} }
if len(intervals) > 1 { if len(intervals) > 1 {
pollingInterval = toDuration(intervals[1]) pollingInterval = toDuration(intervals[1])
} }
return asyncassertion.New(asyncassertion.AsyncAssertionTypeConsistently, actual, testingtsupport.BuildTestingTGomegaFailWrapper(g.t), timeoutInterval, po llingInterval, 0) return asyncassertion.New(asyncassertion.AsyncAssertionTypeConsistently, actual, testingtsupport.BuildTestingTGomegaFailWrapper(g.t), timeoutInterval, po llingInterval, 0)
} }
 End of changes. 73 change blocks. 
185 lines changed or deleted 195 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)