vendor: bump ginkgo, gover
Signed-off-by: Casey Callendrello <cdc@redhat.com>
This commit is contained in:
20
vendor/github.com/onsi/gomega/gbytes/buffer.go
generated
vendored
20
vendor/github.com/onsi/gomega/gbytes/buffer.go
generated
vendored
@ -52,6 +52,23 @@ func BufferWithBytes(bytes []byte) *Buffer {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
BufferReader returns a new gbytes.Buffer that wraps a reader. The reader's contents are read into
|
||||
the Buffer via io.Copy
|
||||
*/
|
||||
func BufferReader(reader io.Reader) *Buffer {
|
||||
b := &Buffer{
|
||||
lock: &sync.Mutex{},
|
||||
}
|
||||
|
||||
go func() {
|
||||
io.Copy(b, reader)
|
||||
b.Close()
|
||||
}()
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
/*
|
||||
Write implements the io.Writer interface
|
||||
*/
|
||||
@ -223,7 +240,6 @@ func (b *Buffer) didSay(re *regexp.Regexp) (bool, []byte) {
|
||||
if loc != nil {
|
||||
b.readCursor += uint64(loc[1])
|
||||
return true, copyOfUnreadBytes
|
||||
} else {
|
||||
return false, copyOfUnreadBytes
|
||||
}
|
||||
return false, copyOfUnreadBytes
|
||||
}
|
||||
|
85
vendor/github.com/onsi/gomega/gbytes/io_wrappers.go
generated
vendored
Normal file
85
vendor/github.com/onsi/gomega/gbytes/io_wrappers.go
generated
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
package gbytes
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ErrTimeout is returned by TimeoutCloser, TimeoutReader, and TimeoutWriter when the underlying Closer/Reader/Writer does not return within the specified timeout
|
||||
var ErrTimeout = errors.New("timeout occurred")
|
||||
|
||||
// TimeoutCloser returns an io.Closer that wraps the passed-in io.Closer. If the underlying Closer fails to close within the alloted timeout ErrTimeout is returned.
|
||||
func TimeoutCloser(c io.Closer, timeout time.Duration) io.Closer {
|
||||
return timeoutReaderWriterCloser{c: c, d: timeout}
|
||||
}
|
||||
|
||||
// TimeoutReader returns an io.Reader that wraps the passed-in io.Reader. If the underlying Reader fails to read within the alloted timeout ErrTimeout is returned.
|
||||
func TimeoutReader(r io.Reader, timeout time.Duration) io.Reader {
|
||||
return timeoutReaderWriterCloser{r: r, d: timeout}
|
||||
}
|
||||
|
||||
// TimeoutWriter returns an io.Writer that wraps the passed-in io.Writer. If the underlying Writer fails to write within the alloted timeout ErrTimeout is returned.
|
||||
func TimeoutWriter(w io.Writer, timeout time.Duration) io.Writer {
|
||||
return timeoutReaderWriterCloser{w: w, d: timeout}
|
||||
}
|
||||
|
||||
type timeoutReaderWriterCloser struct {
|
||||
c io.Closer
|
||||
w io.Writer
|
||||
r io.Reader
|
||||
d time.Duration
|
||||
}
|
||||
|
||||
func (t timeoutReaderWriterCloser) Close() error {
|
||||
done := make(chan struct{})
|
||||
var err error
|
||||
|
||||
go func() {
|
||||
err = t.c.Close()
|
||||
close(done)
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
return err
|
||||
case <-time.After(t.d):
|
||||
return ErrTimeout
|
||||
}
|
||||
}
|
||||
|
||||
func (t timeoutReaderWriterCloser) Read(p []byte) (int, error) {
|
||||
done := make(chan struct{})
|
||||
var n int
|
||||
var err error
|
||||
|
||||
go func() {
|
||||
n, err = t.r.Read(p)
|
||||
close(done)
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
return n, err
|
||||
case <-time.After(t.d):
|
||||
return 0, ErrTimeout
|
||||
}
|
||||
}
|
||||
|
||||
func (t timeoutReaderWriterCloser) Write(p []byte) (int, error) {
|
||||
done := make(chan struct{})
|
||||
var n int
|
||||
var err error
|
||||
|
||||
go func() {
|
||||
n, err = t.w.Write(p)
|
||||
close(done)
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
return n, err
|
||||
case <-time.After(t.d):
|
||||
return 0, ErrTimeout
|
||||
}
|
||||
}
|
13
vendor/github.com/onsi/gomega/gbytes/say_matcher.go
generated
vendored
13
vendor/github.com/onsi/gomega/gbytes/say_matcher.go
generated
vendored
@ -1,3 +1,5 @@
|
||||
// untested sections: 1
|
||||
|
||||
package gbytes
|
||||
|
||||
import (
|
||||
@ -15,14 +17,14 @@ type BufferProvider interface {
|
||||
/*
|
||||
Say is a Gomega matcher that operates on gbytes.Buffers:
|
||||
|
||||
Ω(buffer).Should(Say("something"))
|
||||
Expect(buffer).Should(Say("something"))
|
||||
|
||||
will succeed if the unread portion of the buffer matches the regular expression "something".
|
||||
|
||||
When Say succeeds, it fast forwards the gbytes.Buffer's read cursor to just after the succesful match.
|
||||
When Say succeeds, it fast forwards the gbytes.Buffer's read cursor to just after the successful match.
|
||||
Thus, subsequent calls to Say will only match against the unread portion of the buffer
|
||||
|
||||
Say pairs very well with Eventually. To asser that a buffer eventually receives data matching "[123]-star" within 3 seconds you can:
|
||||
Say pairs very well with Eventually. To assert that a buffer eventually receives data matching "[123]-star" within 3 seconds you can:
|
||||
|
||||
Eventually(buffer, 3).Should(Say("[123]-star"))
|
||||
|
||||
@ -36,12 +38,11 @@ In such cases, Say simply operates on the *gbytes.Buffer returned by Buffer()
|
||||
If the buffer is closed, the Say matcher will tell Eventually to abort.
|
||||
*/
|
||||
func Say(expected string, args ...interface{}) *sayMatcher {
|
||||
formattedRegexp := expected
|
||||
if len(args) > 0 {
|
||||
formattedRegexp = fmt.Sprintf(expected, args...)
|
||||
expected = fmt.Sprintf(expected, args...)
|
||||
}
|
||||
return &sayMatcher{
|
||||
re: regexp.MustCompile(formattedRegexp),
|
||||
re: regexp.MustCompile(expected),
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user