vendor: Mega update all dependencies

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4080
This commit is contained in:
Jakob Borg
2017-04-05 14:34:41 +00:00
parent 49c1527724
commit a1bcc15458
1354 changed files with 55066 additions and 797850 deletions

View File

@@ -26,6 +26,11 @@ func (writer *FakeGinkgoWriter) DumpOutWithHeader(header string) {
writer.EventStream = append(writer.EventStream, "DUMP_WITH_HEADER: "+header)
}
func (writer *FakeGinkgoWriter) Bytes() []byte {
writer.EventStream = append(writer.EventStream, "BYTES")
return nil
}
func (writer *FakeGinkgoWriter) Write(data []byte) (n int, err error) {
return 0, nil
}

View File

@@ -12,6 +12,7 @@ type WriterInterface interface {
Truncate()
DumpOut()
DumpOutWithHeader(header string)
Bytes() []byte
}
type Writer struct {
@@ -40,11 +41,11 @@ func (w *Writer) Write(b []byte) (n int, err error) {
w.lock.Lock()
defer w.lock.Unlock()
n, err = w.buffer.Write(b)
if w.stream {
return w.outWriter.Write(b)
} else {
return w.buffer.Write(b)
}
return n, err
}
func (w *Writer) Truncate() {
@@ -61,6 +62,15 @@ func (w *Writer) DumpOut() {
}
}
func (w *Writer) Bytes() []byte {
w.lock.Lock()
defer w.lock.Unlock()
b := w.buffer.Bytes()
copied := make([]byte, len(b))
copy(copied, b)
return copied
}
func (w *Writer) DumpOutWithHeader(header string) {
w.lock.Lock()
defer w.lock.Unlock()

View File

@@ -1,13 +0,0 @@
package writer_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestWriter(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Writer Suite")
}

View File

@@ -1,75 +0,0 @@
package writer_test
import (
"github.com/onsi/gomega/gbytes"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/internal/writer"
. "github.com/onsi/gomega"
)
var _ = Describe("Writer", func() {
var writer *Writer
var out *gbytes.Buffer
BeforeEach(func() {
out = gbytes.NewBuffer()
writer = New(out)
})
It("should stream directly to the outbuffer by default", func() {
writer.Write([]byte("foo"))
Ω(out).Should(gbytes.Say("foo"))
})
It("should not emit the header when asked to DumpOutWitHeader", func() {
writer.Write([]byte("foo"))
writer.DumpOutWithHeader("my header")
Ω(out).ShouldNot(gbytes.Say("my header"))
Ω(out).Should(gbytes.Say("foo"))
})
Context("when told not to stream", func() {
BeforeEach(func() {
writer.SetStream(false)
})
It("should only write to the buffer when told to DumpOut", func() {
writer.Write([]byte("foo"))
Ω(out).ShouldNot(gbytes.Say("foo"))
writer.DumpOut()
Ω(out).Should(gbytes.Say("foo"))
})
It("should truncate the internal buffer when told to truncate", func() {
writer.Write([]byte("foo"))
writer.Truncate()
writer.DumpOut()
Ω(out).ShouldNot(gbytes.Say("foo"))
writer.Write([]byte("bar"))
writer.DumpOut()
Ω(out).Should(gbytes.Say("bar"))
})
Describe("emitting a header", func() {
Context("when the buffer has content", func() {
It("should emit the header followed by the content", func() {
writer.Write([]byte("foo"))
writer.DumpOutWithHeader("my header")
Ω(out).Should(gbytes.Say("my header"))
Ω(out).Should(gbytes.Say("foo"))
})
})
Context("when the buffer has no content", func() {
It("should not emit the header", func() {
writer.DumpOutWithHeader("my header")
Ω(out).ShouldNot(gbytes.Say("my header"))
})
})
})
})
})