vendor: Mega update all dependencies
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4080
This commit is contained in:
158
vendor/github.com/onsi/gomega/gbytes/buffer_test.go
generated
vendored
158
vendor/github.com/onsi/gomega/gbytes/buffer_test.go
generated
vendored
@@ -1,158 +0,0 @@
|
||||
package gbytes_test
|
||||
|
||||
import (
|
||||
"io"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/gomega/gbytes"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("Buffer", func() {
|
||||
var buffer *Buffer
|
||||
|
||||
BeforeEach(func() {
|
||||
buffer = NewBuffer()
|
||||
})
|
||||
|
||||
Describe("dumping the entire contents of the buffer", func() {
|
||||
It("should return everything that's been written", func() {
|
||||
buffer.Write([]byte("abc"))
|
||||
buffer.Write([]byte("def"))
|
||||
Ω(buffer.Contents()).Should(Equal([]byte("abcdef")))
|
||||
|
||||
Ω(buffer).Should(Say("bcd"))
|
||||
Ω(buffer.Contents()).Should(Equal([]byte("abcdef")))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("creating a buffer with bytes", func() {
|
||||
It("should create the buffer with the cursor set to the beginning", func() {
|
||||
buffer := BufferWithBytes([]byte("abcdef"))
|
||||
Ω(buffer.Contents()).Should(Equal([]byte("abcdef")))
|
||||
Ω(buffer).Should(Say("abc"))
|
||||
Ω(buffer).ShouldNot(Say("abc"))
|
||||
Ω(buffer).Should(Say("def"))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("reading from a buffer", func() {
|
||||
It("should read the current contents of the buffer", func() {
|
||||
buffer := BufferWithBytes([]byte("abcde"))
|
||||
|
||||
dest := make([]byte, 3)
|
||||
n, err := buffer.Read(dest)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(n).Should(Equal(3))
|
||||
Ω(string(dest)).Should(Equal("abc"))
|
||||
|
||||
dest = make([]byte, 3)
|
||||
n, err = buffer.Read(dest)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(n).Should(Equal(2))
|
||||
Ω(string(dest[:n])).Should(Equal("de"))
|
||||
|
||||
n, err = buffer.Read(dest)
|
||||
Ω(err).Should(Equal(io.EOF))
|
||||
Ω(n).Should(Equal(0))
|
||||
})
|
||||
|
||||
Context("after the buffer has been closed", func() {
|
||||
It("returns an error", func() {
|
||||
buffer := BufferWithBytes([]byte("abcde"))
|
||||
|
||||
buffer.Close()
|
||||
|
||||
dest := make([]byte, 3)
|
||||
n, err := buffer.Read(dest)
|
||||
Ω(err).Should(HaveOccurred())
|
||||
Ω(n).Should(Equal(0))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("detecting regular expressions", func() {
|
||||
It("should fire the appropriate channel when the passed in pattern matches, then close it", func(done Done) {
|
||||
go func() {
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
buffer.Write([]byte("abcde"))
|
||||
}()
|
||||
|
||||
A := buffer.Detect("%s", "a.c")
|
||||
B := buffer.Detect("def")
|
||||
|
||||
var gotIt bool
|
||||
select {
|
||||
case gotIt = <-A:
|
||||
case <-B:
|
||||
Fail("should not have gotten here")
|
||||
}
|
||||
|
||||
Ω(gotIt).Should(BeTrue())
|
||||
Eventually(A).Should(BeClosed())
|
||||
|
||||
buffer.Write([]byte("f"))
|
||||
Eventually(B).Should(Receive())
|
||||
Eventually(B).Should(BeClosed())
|
||||
|
||||
close(done)
|
||||
})
|
||||
|
||||
It("should fast-forward the buffer upon detection", func(done Done) {
|
||||
buffer.Write([]byte("abcde"))
|
||||
<-buffer.Detect("abc")
|
||||
Ω(buffer).ShouldNot(Say("abc"))
|
||||
Ω(buffer).Should(Say("de"))
|
||||
close(done)
|
||||
})
|
||||
|
||||
It("should only fast-forward the buffer when the channel is read, and only if doing so would not rewind it", func(done Done) {
|
||||
buffer.Write([]byte("abcde"))
|
||||
A := buffer.Detect("abc")
|
||||
time.Sleep(20 * time.Millisecond) //give the goroutine a chance to detect and write to the channel
|
||||
Ω(buffer).Should(Say("abcd"))
|
||||
<-A
|
||||
Ω(buffer).ShouldNot(Say("d"))
|
||||
Ω(buffer).Should(Say("e"))
|
||||
Eventually(A).Should(BeClosed())
|
||||
close(done)
|
||||
})
|
||||
|
||||
It("should be possible to cancel a detection", func(done Done) {
|
||||
A := buffer.Detect("abc")
|
||||
B := buffer.Detect("def")
|
||||
buffer.CancelDetects()
|
||||
buffer.Write([]byte("abcdef"))
|
||||
Eventually(A).Should(BeClosed())
|
||||
Eventually(B).Should(BeClosed())
|
||||
|
||||
Ω(buffer).Should(Say("bcde"))
|
||||
<-buffer.Detect("f")
|
||||
close(done)
|
||||
})
|
||||
})
|
||||
|
||||
Describe("closing the buffer", func() {
|
||||
It("should error when further write attempts are made", func() {
|
||||
_, err := buffer.Write([]byte("abc"))
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
|
||||
buffer.Close()
|
||||
|
||||
_, err = buffer.Write([]byte("def"))
|
||||
Ω(err).Should(HaveOccurred())
|
||||
|
||||
Ω(buffer.Contents()).Should(Equal([]byte("abc")))
|
||||
})
|
||||
|
||||
It("should be closed", func() {
|
||||
Ω(buffer.Closed()).Should(BeFalse())
|
||||
|
||||
buffer.Close()
|
||||
|
||||
Ω(buffer.Closed()).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
})
|
||||
13
vendor/github.com/onsi/gomega/gbytes/gbuffer_suite_test.go
generated
vendored
13
vendor/github.com/onsi/gomega/gbytes/gbuffer_suite_test.go
generated
vendored
@@ -1,13 +0,0 @@
|
||||
package gbytes_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGbytes(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Gbytes Suite")
|
||||
}
|
||||
2
vendor/github.com/onsi/gomega/gbytes/say_matcher.go
generated
vendored
2
vendor/github.com/onsi/gomega/gbytes/say_matcher.go
generated
vendored
@@ -22,7 +22,7 @@ will succeed if the unread portion of the buffer matches the regular expression
|
||||
When Say succeeds, it fast forwards the gbytes.Buffer's read cursor to just after the succesful 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"))
|
||||
|
||||
|
||||
163
vendor/github.com/onsi/gomega/gbytes/say_matcher_test.go
generated
vendored
163
vendor/github.com/onsi/gomega/gbytes/say_matcher_test.go
generated
vendored
@@ -1,163 +0,0 @@
|
||||
package gbytes_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/gomega/gbytes"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
type speaker struct {
|
||||
buffer *Buffer
|
||||
}
|
||||
|
||||
func (s *speaker) Buffer() *Buffer {
|
||||
return s.buffer
|
||||
}
|
||||
|
||||
var _ = Describe("SayMatcher", func() {
|
||||
var buffer *Buffer
|
||||
|
||||
BeforeEach(func() {
|
||||
buffer = NewBuffer()
|
||||
buffer.Write([]byte("abc"))
|
||||
})
|
||||
|
||||
Context("when actual is not a gexec Buffer, or a BufferProvider", func() {
|
||||
It("should error", func() {
|
||||
failures := InterceptGomegaFailures(func() {
|
||||
Ω("foo").Should(Say("foo"))
|
||||
})
|
||||
Ω(failures[0]).Should(ContainSubstring("*gbytes.Buffer"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a match is found", func() {
|
||||
It("should succeed", func() {
|
||||
Ω(buffer).Should(Say("abc"))
|
||||
})
|
||||
|
||||
It("should support printf-like formatting", func() {
|
||||
Ω(buffer).Should(Say("a%sc", "b"))
|
||||
})
|
||||
|
||||
It("should use a regular expression", func() {
|
||||
Ω(buffer).Should(Say("a.c"))
|
||||
})
|
||||
|
||||
It("should fastforward the buffer", func() {
|
||||
buffer.Write([]byte("def"))
|
||||
Ω(buffer).Should(Say("abcd"))
|
||||
Ω(buffer).Should(Say("ef"))
|
||||
Ω(buffer).ShouldNot(Say("[a-z]"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when no match is found", func() {
|
||||
It("should not error", func() {
|
||||
Ω(buffer).ShouldNot(Say("def"))
|
||||
})
|
||||
|
||||
Context("when the buffer is closed", func() {
|
||||
BeforeEach(func() {
|
||||
buffer.Close()
|
||||
})
|
||||
|
||||
It("should abort an eventually", func() {
|
||||
t := time.Now()
|
||||
failures := InterceptGomegaFailures(func() {
|
||||
Eventually(buffer).Should(Say("def"))
|
||||
})
|
||||
Eventually(buffer).ShouldNot(Say("def"))
|
||||
Ω(time.Since(t)).Should(BeNumerically("<", 500*time.Millisecond))
|
||||
Ω(failures).Should(HaveLen(1))
|
||||
|
||||
t = time.Now()
|
||||
Eventually(buffer).Should(Say("abc"))
|
||||
Ω(time.Since(t)).Should(BeNumerically("<", 500*time.Millisecond))
|
||||
})
|
||||
|
||||
It("should abort a consistently", func() {
|
||||
t := time.Now()
|
||||
Consistently(buffer, 2.0).ShouldNot(Say("def"))
|
||||
Ω(time.Since(t)).Should(BeNumerically("<", 500*time.Millisecond))
|
||||
})
|
||||
|
||||
It("should not error with a synchronous matcher", func() {
|
||||
Ω(buffer).ShouldNot(Say("def"))
|
||||
Ω(buffer).Should(Say("abc"))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a positive match fails", func() {
|
||||
It("should report where it got stuck", func() {
|
||||
Ω(buffer).Should(Say("abc"))
|
||||
buffer.Write([]byte("def"))
|
||||
failures := InterceptGomegaFailures(func() {
|
||||
Ω(buffer).Should(Say("abc"))
|
||||
})
|
||||
Ω(failures[0]).Should(ContainSubstring("Got stuck at:"))
|
||||
Ω(failures[0]).Should(ContainSubstring("def"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a negative match fails", func() {
|
||||
It("should report where it got stuck", func() {
|
||||
failures := InterceptGomegaFailures(func() {
|
||||
Ω(buffer).ShouldNot(Say("abc"))
|
||||
})
|
||||
Ω(failures[0]).Should(ContainSubstring("Saw:"))
|
||||
Ω(failures[0]).Should(ContainSubstring("Which matches the unexpected:"))
|
||||
Ω(failures[0]).Should(ContainSubstring("abc"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a match is not found", func() {
|
||||
It("should not fastforward the buffer", func() {
|
||||
Ω(buffer).ShouldNot(Say("def"))
|
||||
Ω(buffer).Should(Say("abc"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("a nice real-life example", func() {
|
||||
It("should behave well", func() {
|
||||
Ω(buffer).Should(Say("abc"))
|
||||
go func() {
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
buffer.Write([]byte("def"))
|
||||
}()
|
||||
Ω(buffer).ShouldNot(Say("def"))
|
||||
Eventually(buffer).Should(Say("def"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when actual is a BufferProvider", func() {
|
||||
It("should use actual's buffer", func() {
|
||||
s := &speaker{
|
||||
buffer: NewBuffer(),
|
||||
}
|
||||
|
||||
Ω(s).ShouldNot(Say("abc"))
|
||||
|
||||
s.Buffer().Write([]byte("abc"))
|
||||
Ω(s).Should(Say("abc"))
|
||||
})
|
||||
|
||||
It("should abort an eventually", func() {
|
||||
s := &speaker{
|
||||
buffer: NewBuffer(),
|
||||
}
|
||||
|
||||
s.buffer.Close()
|
||||
|
||||
t := time.Now()
|
||||
failures := InterceptGomegaFailures(func() {
|
||||
Eventually(s).Should(Say("def"))
|
||||
})
|
||||
Ω(failures).Should(HaveLen(1))
|
||||
Ω(time.Since(t)).Should(BeNumerically("<", 500*time.Millisecond))
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user