vendor: Mega update all dependencies
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4080
This commit is contained in:
14
vendor/github.com/onsi/ginkgo/internal/leafnodes/benchmarker.go
generated
vendored
14
vendor/github.com/onsi/ginkgo/internal/leafnodes/benchmarker.go
generated
vendored
@@ -28,20 +28,27 @@ func (b *benchmarker) Time(name string, body func(), info ...interface{}) (elaps
|
||||
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
measurement := b.getMeasurement(name, "Fastest Time", "Slowest Time", "Average Time", "s", info...)
|
||||
measurement := b.getMeasurement(name, "Fastest Time", "Slowest Time", "Average Time", "s", 3, info...)
|
||||
measurement.Results = append(measurement.Results, elapsedTime.Seconds())
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (b *benchmarker) RecordValue(name string, value float64, info ...interface{}) {
|
||||
measurement := b.getMeasurement(name, "Smallest", " Largest", " Average", "", info...)
|
||||
measurement := b.getMeasurement(name, "Smallest", " Largest", " Average", "", 3, info...)
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
measurement.Results = append(measurement.Results, value)
|
||||
}
|
||||
|
||||
func (b *benchmarker) getMeasurement(name string, smallestLabel string, largestLabel string, averageLabel string, units string, info ...interface{}) *types.SpecMeasurement {
|
||||
func (b *benchmarker) RecordValueWithPrecision(name string, value float64, units string, precision int, info ...interface{}) {
|
||||
measurement := b.getMeasurement(name, "Smallest", " Largest", " Average", units, precision, info...)
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
measurement.Results = append(measurement.Results, value)
|
||||
}
|
||||
|
||||
func (b *benchmarker) getMeasurement(name string, smallestLabel string, largestLabel string, averageLabel string, units string, precision int, info ...interface{}) *types.SpecMeasurement {
|
||||
measurement, ok := b.measurements[name]
|
||||
if !ok {
|
||||
var computedInfo interface{}
|
||||
@@ -57,6 +64,7 @@ func (b *benchmarker) getMeasurement(name string, smallestLabel string, largestL
|
||||
LargestLabel: largestLabel,
|
||||
AverageLabel: averageLabel,
|
||||
Units: units,
|
||||
Precision: precision,
|
||||
Results: make([]float64, 0),
|
||||
}
|
||||
b.measurements[name] = measurement
|
||||
|
||||
22
vendor/github.com/onsi/ginkgo/internal/leafnodes/it_node_test.go
generated
vendored
22
vendor/github.com/onsi/ginkgo/internal/leafnodes/it_node_test.go
generated
vendored
@@ -1,22 +0,0 @@
|
||||
package leafnodes_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/internal/leafnodes"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
)
|
||||
|
||||
var _ = Describe("It Nodes", func() {
|
||||
It("should report the correct type, text, flag, and code location", func() {
|
||||
codeLocation := codelocation.New(0)
|
||||
it := NewItNode("my it node", func() {}, types.FlagTypeFocused, codeLocation, 0, nil, 3)
|
||||
Ω(it.Type()).Should(Equal(types.SpecComponentTypeIt))
|
||||
Ω(it.Flag()).Should(Equal(types.FlagTypeFocused))
|
||||
Ω(it.Text()).Should(Equal("my it node"))
|
||||
Ω(it.CodeLocation()).Should(Equal(codeLocation))
|
||||
Ω(it.Samples()).Should(Equal(1))
|
||||
})
|
||||
})
|
||||
13
vendor/github.com/onsi/ginkgo/internal/leafnodes/leaf_node_suite_test.go
generated
vendored
13
vendor/github.com/onsi/ginkgo/internal/leafnodes/leaf_node_suite_test.go
generated
vendored
@@ -1,13 +0,0 @@
|
||||
package leafnodes_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLeafNode(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "LeafNode Suite")
|
||||
}
|
||||
109
vendor/github.com/onsi/ginkgo/internal/leafnodes/measure_node_test.go
generated
vendored
109
vendor/github.com/onsi/ginkgo/internal/leafnodes/measure_node_test.go
generated
vendored
@@ -1,109 +0,0 @@
|
||||
package leafnodes_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/internal/leafnodes"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
Failer "github.com/onsi/ginkgo/internal/failer"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
"time"
|
||||
)
|
||||
|
||||
var _ = Describe("Measure Nodes", func() {
|
||||
It("should report the correct type, text, flag, and code location", func() {
|
||||
codeLocation := codelocation.New(0)
|
||||
measure := NewMeasureNode("my measure node", func(b Benchmarker) {}, types.FlagTypeFocused, codeLocation, 10, nil, 3)
|
||||
Ω(measure.Type()).Should(Equal(types.SpecComponentTypeMeasure))
|
||||
Ω(measure.Flag()).Should(Equal(types.FlagTypeFocused))
|
||||
Ω(measure.Text()).Should(Equal("my measure node"))
|
||||
Ω(measure.CodeLocation()).Should(Equal(codeLocation))
|
||||
Ω(measure.Samples()).Should(Equal(10))
|
||||
})
|
||||
|
||||
Describe("benchmarking", func() {
|
||||
var measure *MeasureNode
|
||||
|
||||
Describe("Value", func() {
|
||||
BeforeEach(func() {
|
||||
measure = NewMeasureNode("the measurement", func(b Benchmarker) {
|
||||
b.RecordValue("foo", 7, "info!")
|
||||
b.RecordValue("foo", 2)
|
||||
b.RecordValue("foo", 3)
|
||||
b.RecordValue("bar", 0.3)
|
||||
b.RecordValue("bar", 0.1)
|
||||
b.RecordValue("bar", 0.5)
|
||||
b.RecordValue("bar", 0.7)
|
||||
}, types.FlagTypeFocused, codelocation.New(0), 1, Failer.New(), 3)
|
||||
Ω(measure.Run()).Should(Equal(types.SpecStatePassed))
|
||||
})
|
||||
|
||||
It("records passed in values and reports on them", func() {
|
||||
report := measure.MeasurementsReport()
|
||||
Ω(report).Should(HaveLen(2))
|
||||
Ω(report["foo"].Name).Should(Equal("foo"))
|
||||
Ω(report["foo"].Info).Should(Equal("info!"))
|
||||
Ω(report["foo"].Order).Should(Equal(0))
|
||||
Ω(report["foo"].SmallestLabel).Should(Equal("Smallest"))
|
||||
Ω(report["foo"].LargestLabel).Should(Equal(" Largest"))
|
||||
Ω(report["foo"].AverageLabel).Should(Equal(" Average"))
|
||||
Ω(report["foo"].Units).Should(Equal(""))
|
||||
Ω(report["foo"].Results).Should(Equal([]float64{7, 2, 3}))
|
||||
Ω(report["foo"].Smallest).Should(BeNumerically("==", 2))
|
||||
Ω(report["foo"].Largest).Should(BeNumerically("==", 7))
|
||||
Ω(report["foo"].Average).Should(BeNumerically("==", 4))
|
||||
Ω(report["foo"].StdDeviation).Should(BeNumerically("~", 2.16, 0.01))
|
||||
|
||||
Ω(report["bar"].Name).Should(Equal("bar"))
|
||||
Ω(report["bar"].Info).Should(BeNil())
|
||||
Ω(report["bar"].SmallestLabel).Should(Equal("Smallest"))
|
||||
Ω(report["bar"].Order).Should(Equal(1))
|
||||
Ω(report["bar"].LargestLabel).Should(Equal(" Largest"))
|
||||
Ω(report["bar"].AverageLabel).Should(Equal(" Average"))
|
||||
Ω(report["bar"].Units).Should(Equal(""))
|
||||
Ω(report["bar"].Results).Should(Equal([]float64{0.3, 0.1, 0.5, 0.7}))
|
||||
Ω(report["bar"].Smallest).Should(BeNumerically("==", 0.1))
|
||||
Ω(report["bar"].Largest).Should(BeNumerically("==", 0.7))
|
||||
Ω(report["bar"].Average).Should(BeNumerically("==", 0.4))
|
||||
Ω(report["bar"].StdDeviation).Should(BeNumerically("~", 0.22, 0.01))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Time", func() {
|
||||
BeforeEach(func() {
|
||||
measure = NewMeasureNode("the measurement", func(b Benchmarker) {
|
||||
b.Time("foo", func() {
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}, "info!")
|
||||
b.Time("foo", func() {
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
})
|
||||
b.Time("foo", func() {
|
||||
time.Sleep(170 * time.Millisecond)
|
||||
})
|
||||
}, types.FlagTypeFocused, codelocation.New(0), 1, Failer.New(), 3)
|
||||
Ω(measure.Run()).Should(Equal(types.SpecStatePassed))
|
||||
})
|
||||
|
||||
It("records passed in values and reports on them", func() {
|
||||
report := measure.MeasurementsReport()
|
||||
Ω(report).Should(HaveLen(1))
|
||||
Ω(report["foo"].Name).Should(Equal("foo"))
|
||||
Ω(report["foo"].Info).Should(Equal("info!"))
|
||||
Ω(report["foo"].SmallestLabel).Should(Equal("Fastest Time"))
|
||||
Ω(report["foo"].LargestLabel).Should(Equal("Slowest Time"))
|
||||
Ω(report["foo"].AverageLabel).Should(Equal("Average Time"))
|
||||
Ω(report["foo"].Units).Should(Equal("s"))
|
||||
Ω(report["foo"].Results).Should(HaveLen(3))
|
||||
Ω(report["foo"].Results[0]).Should(BeNumerically("~", 0.1, 0.01))
|
||||
Ω(report["foo"].Results[1]).Should(BeNumerically("~", 0.2, 0.01))
|
||||
Ω(report["foo"].Results[2]).Should(BeNumerically("~", 0.17, 0.01))
|
||||
Ω(report["foo"].Smallest).Should(BeNumerically("~", 0.1, 0.01))
|
||||
Ω(report["foo"].Largest).Should(BeNumerically("~", 0.2, 0.01))
|
||||
Ω(report["foo"].Average).Should(BeNumerically("~", 0.16, 0.01))
|
||||
Ω(report["foo"].StdDeviation).Should(BeNumerically("~", 0.04, 0.01))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
40
vendor/github.com/onsi/ginkgo/internal/leafnodes/setup_nodes_test.go
generated
vendored
40
vendor/github.com/onsi/ginkgo/internal/leafnodes/setup_nodes_test.go
generated
vendored
@@ -1,40 +0,0 @@
|
||||
package leafnodes_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
. "github.com/onsi/ginkgo/internal/leafnodes"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
)
|
||||
|
||||
var _ = Describe("Setup Nodes", func() {
|
||||
Describe("BeforeEachNodes", func() {
|
||||
It("should report the correct type and code location", func() {
|
||||
codeLocation := codelocation.New(0)
|
||||
beforeEach := NewBeforeEachNode(func() {}, codeLocation, 0, nil, 3)
|
||||
Ω(beforeEach.Type()).Should(Equal(types.SpecComponentTypeBeforeEach))
|
||||
Ω(beforeEach.CodeLocation()).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("AfterEachNodes", func() {
|
||||
It("should report the correct type and code location", func() {
|
||||
codeLocation := codelocation.New(0)
|
||||
afterEach := NewAfterEachNode(func() {}, codeLocation, 0, nil, 3)
|
||||
Ω(afterEach.Type()).Should(Equal(types.SpecComponentTypeAfterEach))
|
||||
Ω(afterEach.CodeLocation()).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("JustBeforeEachNodes", func() {
|
||||
It("should report the correct type and code location", func() {
|
||||
codeLocation := codelocation.New(0)
|
||||
justBeforeEach := NewJustBeforeEachNode(func() {}, codeLocation, 0, nil, 3)
|
||||
Ω(justBeforeEach.Type()).Should(Equal(types.SpecComponentTypeJustBeforeEach))
|
||||
Ω(justBeforeEach.CodeLocation()).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
})
|
||||
361
vendor/github.com/onsi/ginkgo/internal/leafnodes/shared_runner_test.go
generated
vendored
361
vendor/github.com/onsi/ginkgo/internal/leafnodes/shared_runner_test.go
generated
vendored
@@ -1,361 +0,0 @@
|
||||
package leafnodes_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/internal/leafnodes"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"reflect"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
Failer "github.com/onsi/ginkgo/internal/failer"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
)
|
||||
|
||||
type runnable interface {
|
||||
Run() (outcome types.SpecState, failure types.SpecFailure)
|
||||
CodeLocation() types.CodeLocation
|
||||
}
|
||||
|
||||
func SynchronousSharedRunnerBehaviors(build func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable, componentType types.SpecComponentType, componentIndex int) {
|
||||
var (
|
||||
outcome types.SpecState
|
||||
failure types.SpecFailure
|
||||
|
||||
failer *Failer.Failer
|
||||
|
||||
componentCodeLocation types.CodeLocation
|
||||
innerCodeLocation types.CodeLocation
|
||||
|
||||
didRun bool
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
failer = Failer.New()
|
||||
componentCodeLocation = codelocation.New(0)
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
|
||||
didRun = false
|
||||
})
|
||||
|
||||
Describe("synchronous functions", func() {
|
||||
Context("when the function passes", func() {
|
||||
BeforeEach(func() {
|
||||
outcome, failure = build(func() {
|
||||
didRun = true
|
||||
}, 0, failer, componentCodeLocation).Run()
|
||||
})
|
||||
|
||||
It("should have a succesful outcome", func() {
|
||||
Ω(didRun).Should(BeTrue())
|
||||
|
||||
Ω(outcome).Should(Equal(types.SpecStatePassed))
|
||||
Ω(failure).Should(BeZero())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a failure occurs", func() {
|
||||
BeforeEach(func() {
|
||||
outcome, failure = build(func() {
|
||||
didRun = true
|
||||
failer.Fail("bam", innerCodeLocation)
|
||||
panic("should not matter")
|
||||
}, 0, failer, componentCodeLocation).Run()
|
||||
})
|
||||
|
||||
It("should return the failure", func() {
|
||||
Ω(didRun).Should(BeTrue())
|
||||
|
||||
Ω(outcome).Should(Equal(types.SpecStateFailed))
|
||||
Ω(failure).Should(Equal(types.SpecFailure{
|
||||
Message: "bam",
|
||||
Location: innerCodeLocation,
|
||||
ForwardedPanic: "",
|
||||
ComponentIndex: componentIndex,
|
||||
ComponentType: componentType,
|
||||
ComponentCodeLocation: componentCodeLocation,
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a panic occurs", func() {
|
||||
BeforeEach(func() {
|
||||
outcome, failure = build(func() {
|
||||
didRun = true
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
panic("ack!")
|
||||
}, 0, failer, componentCodeLocation).Run()
|
||||
})
|
||||
|
||||
It("should return the panic", func() {
|
||||
Ω(didRun).Should(BeTrue())
|
||||
|
||||
Ω(outcome).Should(Equal(types.SpecStatePanicked))
|
||||
Ω(failure.ForwardedPanic).Should(Equal("ack!"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a panic occurs with a nil value", func() {
|
||||
BeforeEach(func() {
|
||||
outcome, failure = build(func() {
|
||||
didRun = true
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
panic(nil)
|
||||
}, 0, failer, componentCodeLocation).Run()
|
||||
})
|
||||
|
||||
It("should return the nil-valued panic", func() {
|
||||
Ω(didRun).Should(BeTrue())
|
||||
|
||||
Ω(outcome).Should(Equal(types.SpecStatePanicked))
|
||||
Ω(failure.ForwardedPanic).Should(Equal("<nil>"))
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
func AsynchronousSharedRunnerBehaviors(build func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable, componentType types.SpecComponentType, componentIndex int) {
|
||||
var (
|
||||
outcome types.SpecState
|
||||
failure types.SpecFailure
|
||||
|
||||
failer *Failer.Failer
|
||||
|
||||
componentCodeLocation types.CodeLocation
|
||||
innerCodeLocation types.CodeLocation
|
||||
|
||||
didRun bool
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
failer = Failer.New()
|
||||
componentCodeLocation = codelocation.New(0)
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
|
||||
didRun = false
|
||||
})
|
||||
|
||||
Describe("asynchronous functions", func() {
|
||||
var timeoutDuration time.Duration
|
||||
|
||||
BeforeEach(func() {
|
||||
timeoutDuration = time.Duration(1 * float64(time.Second))
|
||||
})
|
||||
|
||||
Context("when running", func() {
|
||||
It("should run the function as a goroutine, and block until it's done", func() {
|
||||
initialNumberOfGoRoutines := runtime.NumGoroutine()
|
||||
numberOfGoRoutines := 0
|
||||
|
||||
build(func(done Done) {
|
||||
didRun = true
|
||||
numberOfGoRoutines = runtime.NumGoroutine()
|
||||
close(done)
|
||||
}, timeoutDuration, failer, componentCodeLocation).Run()
|
||||
|
||||
Ω(didRun).Should(BeTrue())
|
||||
Ω(numberOfGoRoutines).Should(BeNumerically(">=", initialNumberOfGoRoutines+1))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the function passes", func() {
|
||||
BeforeEach(func() {
|
||||
outcome, failure = build(func(done Done) {
|
||||
didRun = true
|
||||
close(done)
|
||||
}, timeoutDuration, failer, componentCodeLocation).Run()
|
||||
})
|
||||
|
||||
It("should have a succesful outcome", func() {
|
||||
Ω(didRun).Should(BeTrue())
|
||||
Ω(outcome).Should(Equal(types.SpecStatePassed))
|
||||
Ω(failure).Should(BeZero())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the function fails", func() {
|
||||
BeforeEach(func() {
|
||||
outcome, failure = build(func(done Done) {
|
||||
didRun = true
|
||||
failer.Fail("bam", innerCodeLocation)
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
panic("doesn't matter")
|
||||
close(done)
|
||||
}, 10*time.Millisecond, failer, componentCodeLocation).Run()
|
||||
})
|
||||
|
||||
It("should return the failure", func() {
|
||||
Ω(didRun).Should(BeTrue())
|
||||
|
||||
Ω(outcome).Should(Equal(types.SpecStateFailed))
|
||||
Ω(failure).Should(Equal(types.SpecFailure{
|
||||
Message: "bam",
|
||||
Location: innerCodeLocation,
|
||||
ForwardedPanic: "",
|
||||
ComponentIndex: componentIndex,
|
||||
ComponentType: componentType,
|
||||
ComponentCodeLocation: componentCodeLocation,
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the function times out", func() {
|
||||
var guard chan struct{}
|
||||
|
||||
BeforeEach(func() {
|
||||
guard = make(chan struct{})
|
||||
outcome, failure = build(func(done Done) {
|
||||
didRun = true
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
close(guard)
|
||||
panic("doesn't matter")
|
||||
close(done)
|
||||
}, 10*time.Millisecond, failer, componentCodeLocation).Run()
|
||||
})
|
||||
|
||||
It("should return the timeout", func() {
|
||||
<-guard
|
||||
Ω(didRun).Should(BeTrue())
|
||||
|
||||
Ω(outcome).Should(Equal(types.SpecStateTimedOut))
|
||||
Ω(failure).Should(Equal(types.SpecFailure{
|
||||
Message: "Timed out",
|
||||
Location: componentCodeLocation,
|
||||
ForwardedPanic: "",
|
||||
ComponentIndex: componentIndex,
|
||||
ComponentType: componentType,
|
||||
ComponentCodeLocation: componentCodeLocation,
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the function panics", func() {
|
||||
BeforeEach(func() {
|
||||
outcome, failure = build(func(done Done) {
|
||||
didRun = true
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
panic("ack!")
|
||||
}, 100*time.Millisecond, failer, componentCodeLocation).Run()
|
||||
})
|
||||
|
||||
It("should return the panic", func() {
|
||||
Ω(didRun).Should(BeTrue())
|
||||
|
||||
Ω(outcome).Should(Equal(types.SpecStatePanicked))
|
||||
Ω(failure.ForwardedPanic).Should(Equal("ack!"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the function panics with a nil value", func() {
|
||||
BeforeEach(func() {
|
||||
outcome, failure = build(func(done Done) {
|
||||
didRun = true
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
panic(nil)
|
||||
}, 100*time.Millisecond, failer, componentCodeLocation).Run()
|
||||
})
|
||||
|
||||
It("should return the nil-valued panic", func() {
|
||||
Ω(didRun).Should(BeTrue())
|
||||
|
||||
Ω(outcome).Should(Equal(types.SpecStatePanicked))
|
||||
Ω(failure.ForwardedPanic).Should(Equal("<nil>"))
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func InvalidSharedRunnerBehaviors(build func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable, componentType types.SpecComponentType) {
|
||||
var (
|
||||
failer *Failer.Failer
|
||||
componentCodeLocation types.CodeLocation
|
||||
innerCodeLocation types.CodeLocation
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
failer = Failer.New()
|
||||
componentCodeLocation = codelocation.New(0)
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
})
|
||||
|
||||
Describe("invalid functions", func() {
|
||||
Context("when passed something that's not a function", func() {
|
||||
It("should panic", func() {
|
||||
Ω(func() {
|
||||
build("not a function", 0, failer, componentCodeLocation)
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the function takes the wrong kind of argument", func() {
|
||||
It("should panic", func() {
|
||||
Ω(func() {
|
||||
build(func(oops string) {}, 0, failer, componentCodeLocation)
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the function takes more than one argument", func() {
|
||||
It("should panic", func() {
|
||||
Ω(func() {
|
||||
build(func(done Done, oops string) {}, 0, failer, componentCodeLocation)
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
var _ = Describe("Shared RunnableNode behavior", func() {
|
||||
Describe("It Nodes", func() {
|
||||
build := func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable {
|
||||
return NewItNode("", body, types.FlagTypeFocused, componentCodeLocation, timeout, failer, 3)
|
||||
}
|
||||
|
||||
SynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeIt, 3)
|
||||
AsynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeIt, 3)
|
||||
InvalidSharedRunnerBehaviors(build, types.SpecComponentTypeIt)
|
||||
})
|
||||
|
||||
Describe("Measure Nodes", func() {
|
||||
build := func(body interface{}, _ time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable {
|
||||
return NewMeasureNode("", func(Benchmarker) {
|
||||
reflect.ValueOf(body).Call([]reflect.Value{})
|
||||
}, types.FlagTypeFocused, componentCodeLocation, 10, failer, 3)
|
||||
}
|
||||
|
||||
SynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeMeasure, 3)
|
||||
})
|
||||
|
||||
Describe("BeforeEach Nodes", func() {
|
||||
build := func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable {
|
||||
return NewBeforeEachNode(body, componentCodeLocation, timeout, failer, 3)
|
||||
}
|
||||
|
||||
SynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeBeforeEach, 3)
|
||||
AsynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeBeforeEach, 3)
|
||||
InvalidSharedRunnerBehaviors(build, types.SpecComponentTypeBeforeEach)
|
||||
})
|
||||
|
||||
Describe("AfterEach Nodes", func() {
|
||||
build := func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable {
|
||||
return NewAfterEachNode(body, componentCodeLocation, timeout, failer, 3)
|
||||
}
|
||||
|
||||
SynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeAfterEach, 3)
|
||||
AsynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeAfterEach, 3)
|
||||
InvalidSharedRunnerBehaviors(build, types.SpecComponentTypeAfterEach)
|
||||
})
|
||||
|
||||
Describe("JustBeforeEach Nodes", func() {
|
||||
build := func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable {
|
||||
return NewJustBeforeEachNode(body, componentCodeLocation, timeout, failer, 3)
|
||||
}
|
||||
|
||||
SynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeJustBeforeEach, 3)
|
||||
AsynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeJustBeforeEach, 3)
|
||||
InvalidSharedRunnerBehaviors(build, types.SpecComponentTypeJustBeforeEach)
|
||||
})
|
||||
})
|
||||
230
vendor/github.com/onsi/ginkgo/internal/leafnodes/suite_nodes_test.go
generated
vendored
230
vendor/github.com/onsi/ginkgo/internal/leafnodes/suite_nodes_test.go
generated
vendored
@@ -1,230 +0,0 @@
|
||||
package leafnodes_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
. "github.com/onsi/ginkgo/internal/leafnodes"
|
||||
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
Failer "github.com/onsi/ginkgo/internal/failer"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
)
|
||||
|
||||
var _ = Describe("SuiteNodes", func() {
|
||||
Describe("BeforeSuite nodes", func() {
|
||||
var befSuite SuiteNode
|
||||
var failer *Failer.Failer
|
||||
var codeLocation types.CodeLocation
|
||||
var innerCodeLocation types.CodeLocation
|
||||
var outcome bool
|
||||
|
||||
BeforeEach(func() {
|
||||
failer = Failer.New()
|
||||
codeLocation = codelocation.New(0)
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
})
|
||||
|
||||
Context("when the body passes", func() {
|
||||
BeforeEach(func() {
|
||||
befSuite = NewBeforeSuiteNode(func() {
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}, codeLocation, 0, failer)
|
||||
outcome = befSuite.Run(0, 0, "")
|
||||
})
|
||||
|
||||
It("should return true when run and report as passed", func() {
|
||||
Ω(outcome).Should(BeTrue())
|
||||
Ω(befSuite.Passed()).Should(BeTrue())
|
||||
})
|
||||
|
||||
It("should have the correct summary", func() {
|
||||
summary := befSuite.Summary()
|
||||
Ω(summary.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite))
|
||||
Ω(summary.CodeLocation).Should(Equal(codeLocation))
|
||||
Ω(summary.State).Should(Equal(types.SpecStatePassed))
|
||||
Ω(summary.RunTime).Should(BeNumerically(">=", 10*time.Millisecond))
|
||||
Ω(summary.Failure).Should(BeZero())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the body fails", func() {
|
||||
BeforeEach(func() {
|
||||
befSuite = NewBeforeSuiteNode(func() {
|
||||
failer.Fail("oops", innerCodeLocation)
|
||||
}, codeLocation, 0, failer)
|
||||
outcome = befSuite.Run(0, 0, "")
|
||||
})
|
||||
|
||||
It("should return false when run and report as failed", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(befSuite.Passed()).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should have the correct summary", func() {
|
||||
summary := befSuite.Summary()
|
||||
Ω(summary.State).Should(Equal(types.SpecStateFailed))
|
||||
Ω(summary.Failure.Message).Should(Equal("oops"))
|
||||
Ω(summary.Failure.Location).Should(Equal(innerCodeLocation))
|
||||
Ω(summary.Failure.ForwardedPanic).Should(BeEmpty())
|
||||
Ω(summary.Failure.ComponentIndex).Should(Equal(0))
|
||||
Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite))
|
||||
Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the body times out", func() {
|
||||
BeforeEach(func() {
|
||||
befSuite = NewBeforeSuiteNode(func(done Done) {
|
||||
}, codeLocation, time.Millisecond, failer)
|
||||
outcome = befSuite.Run(0, 0, "")
|
||||
})
|
||||
|
||||
It("should return false when run and report as failed", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(befSuite.Passed()).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should have the correct summary", func() {
|
||||
summary := befSuite.Summary()
|
||||
Ω(summary.State).Should(Equal(types.SpecStateTimedOut))
|
||||
Ω(summary.Failure.ForwardedPanic).Should(BeEmpty())
|
||||
Ω(summary.Failure.ComponentIndex).Should(Equal(0))
|
||||
Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite))
|
||||
Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the body panics", func() {
|
||||
BeforeEach(func() {
|
||||
befSuite = NewBeforeSuiteNode(func() {
|
||||
panic("bam")
|
||||
}, codeLocation, 0, failer)
|
||||
outcome = befSuite.Run(0, 0, "")
|
||||
})
|
||||
|
||||
It("should return false when run and report as failed", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(befSuite.Passed()).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should have the correct summary", func() {
|
||||
summary := befSuite.Summary()
|
||||
Ω(summary.State).Should(Equal(types.SpecStatePanicked))
|
||||
Ω(summary.Failure.ForwardedPanic).Should(Equal("bam"))
|
||||
Ω(summary.Failure.ComponentIndex).Should(Equal(0))
|
||||
Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite))
|
||||
Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("AfterSuite nodes", func() {
|
||||
var aftSuite SuiteNode
|
||||
var failer *Failer.Failer
|
||||
var codeLocation types.CodeLocation
|
||||
var innerCodeLocation types.CodeLocation
|
||||
var outcome bool
|
||||
|
||||
BeforeEach(func() {
|
||||
failer = Failer.New()
|
||||
codeLocation = codelocation.New(0)
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
})
|
||||
|
||||
Context("when the body passes", func() {
|
||||
BeforeEach(func() {
|
||||
aftSuite = NewAfterSuiteNode(func() {
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}, codeLocation, 0, failer)
|
||||
outcome = aftSuite.Run(0, 0, "")
|
||||
})
|
||||
|
||||
It("should return true when run and report as passed", func() {
|
||||
Ω(outcome).Should(BeTrue())
|
||||
Ω(aftSuite.Passed()).Should(BeTrue())
|
||||
})
|
||||
|
||||
It("should have the correct summary", func() {
|
||||
summary := aftSuite.Summary()
|
||||
Ω(summary.ComponentType).Should(Equal(types.SpecComponentTypeAfterSuite))
|
||||
Ω(summary.CodeLocation).Should(Equal(codeLocation))
|
||||
Ω(summary.State).Should(Equal(types.SpecStatePassed))
|
||||
Ω(summary.RunTime).Should(BeNumerically(">=", 10*time.Millisecond))
|
||||
Ω(summary.Failure).Should(BeZero())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the body fails", func() {
|
||||
BeforeEach(func() {
|
||||
aftSuite = NewAfterSuiteNode(func() {
|
||||
failer.Fail("oops", innerCodeLocation)
|
||||
}, codeLocation, 0, failer)
|
||||
outcome = aftSuite.Run(0, 0, "")
|
||||
})
|
||||
|
||||
It("should return false when run and report as failed", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(aftSuite.Passed()).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should have the correct summary", func() {
|
||||
summary := aftSuite.Summary()
|
||||
Ω(summary.State).Should(Equal(types.SpecStateFailed))
|
||||
Ω(summary.Failure.Message).Should(Equal("oops"))
|
||||
Ω(summary.Failure.Location).Should(Equal(innerCodeLocation))
|
||||
Ω(summary.Failure.ForwardedPanic).Should(BeEmpty())
|
||||
Ω(summary.Failure.ComponentIndex).Should(Equal(0))
|
||||
Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeAfterSuite))
|
||||
Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the body times out", func() {
|
||||
BeforeEach(func() {
|
||||
aftSuite = NewAfterSuiteNode(func(done Done) {
|
||||
}, codeLocation, time.Millisecond, failer)
|
||||
outcome = aftSuite.Run(0, 0, "")
|
||||
})
|
||||
|
||||
It("should return false when run and report as failed", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(aftSuite.Passed()).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should have the correct summary", func() {
|
||||
summary := aftSuite.Summary()
|
||||
Ω(summary.State).Should(Equal(types.SpecStateTimedOut))
|
||||
Ω(summary.Failure.ForwardedPanic).Should(BeEmpty())
|
||||
Ω(summary.Failure.ComponentIndex).Should(Equal(0))
|
||||
Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeAfterSuite))
|
||||
Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the body panics", func() {
|
||||
BeforeEach(func() {
|
||||
aftSuite = NewAfterSuiteNode(func() {
|
||||
panic("bam")
|
||||
}, codeLocation, 0, failer)
|
||||
outcome = aftSuite.Run(0, 0, "")
|
||||
})
|
||||
|
||||
It("should return false when run and report as failed", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(aftSuite.Passed()).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should have the correct summary", func() {
|
||||
summary := aftSuite.Summary()
|
||||
Ω(summary.State).Should(Equal(types.SpecStatePanicked))
|
||||
Ω(summary.Failure.ForwardedPanic).Should(Equal("bam"))
|
||||
Ω(summary.Failure.ComponentIndex).Should(Equal(0))
|
||||
Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeAfterSuite))
|
||||
Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
196
vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_after_suite_node_test.go
generated
vendored
196
vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_after_suite_node_test.go
generated
vendored
@@ -1,196 +0,0 @@
|
||||
package leafnodes_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/internal/leafnodes"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
. "github.com/onsi/gomega"
|
||||
"sync"
|
||||
|
||||
"github.com/onsi/gomega/ghttp"
|
||||
"net/http"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
Failer "github.com/onsi/ginkgo/internal/failer"
|
||||
"time"
|
||||
)
|
||||
|
||||
var _ = Describe("SynchronizedAfterSuiteNode", func() {
|
||||
var failer *Failer.Failer
|
||||
var node SuiteNode
|
||||
var codeLocation types.CodeLocation
|
||||
var innerCodeLocation types.CodeLocation
|
||||
var outcome bool
|
||||
var server *ghttp.Server
|
||||
var things []string
|
||||
var lock *sync.Mutex
|
||||
|
||||
BeforeEach(func() {
|
||||
things = []string{}
|
||||
server = ghttp.NewServer()
|
||||
codeLocation = codelocation.New(0)
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
failer = Failer.New()
|
||||
lock = &sync.Mutex{}
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
server.Close()
|
||||
})
|
||||
|
||||
newNode := func(bodyA interface{}, bodyB interface{}) SuiteNode {
|
||||
return NewSynchronizedAfterSuiteNode(bodyA, bodyB, codeLocation, time.Millisecond, failer)
|
||||
}
|
||||
|
||||
ranThing := func(thing string) {
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
things = append(things, thing)
|
||||
}
|
||||
|
||||
thingsThatRan := func() []string {
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
return things
|
||||
}
|
||||
|
||||
Context("when not running in parallel", func() {
|
||||
Context("when all is well", func() {
|
||||
BeforeEach(func() {
|
||||
node = newNode(func() {
|
||||
ranThing("A")
|
||||
}, func() {
|
||||
ranThing("B")
|
||||
})
|
||||
|
||||
outcome = node.Run(1, 1, server.URL())
|
||||
})
|
||||
|
||||
It("should run A, then B", func() {
|
||||
Ω(thingsThatRan()).Should(Equal([]string{"A", "B"}))
|
||||
})
|
||||
|
||||
It("should report success", func() {
|
||||
Ω(outcome).Should(BeTrue())
|
||||
Ω(node.Passed()).Should(BeTrue())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStatePassed))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when A fails", func() {
|
||||
BeforeEach(func() {
|
||||
node = newNode(func() {
|
||||
ranThing("A")
|
||||
failer.Fail("bam", innerCodeLocation)
|
||||
}, func() {
|
||||
ranThing("B")
|
||||
})
|
||||
|
||||
outcome = node.Run(1, 1, server.URL())
|
||||
})
|
||||
|
||||
It("should still run B", func() {
|
||||
Ω(thingsThatRan()).Should(Equal([]string{"A", "B"}))
|
||||
})
|
||||
|
||||
It("should report failure", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(node.Passed()).Should(BeFalse())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStateFailed))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when B fails", func() {
|
||||
BeforeEach(func() {
|
||||
node = newNode(func() {
|
||||
ranThing("A")
|
||||
}, func() {
|
||||
ranThing("B")
|
||||
failer.Fail("bam", innerCodeLocation)
|
||||
})
|
||||
|
||||
outcome = node.Run(1, 1, server.URL())
|
||||
})
|
||||
|
||||
It("should run all the things", func() {
|
||||
Ω(thingsThatRan()).Should(Equal([]string{"A", "B"}))
|
||||
})
|
||||
|
||||
It("should report failure", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(node.Passed()).Should(BeFalse())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStateFailed))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("when running in parallel", func() {
|
||||
Context("as the first node", func() {
|
||||
BeforeEach(func() {
|
||||
server.AppendHandlers(ghttp.CombineHandlers(
|
||||
ghttp.VerifyRequest("GET", "/RemoteAfterSuiteData"),
|
||||
func(writer http.ResponseWriter, request *http.Request) {
|
||||
ranThing("Request1")
|
||||
},
|
||||
ghttp.RespondWithJSONEncoded(200, types.RemoteAfterSuiteData{false}),
|
||||
), ghttp.CombineHandlers(
|
||||
ghttp.VerifyRequest("GET", "/RemoteAfterSuiteData"),
|
||||
func(writer http.ResponseWriter, request *http.Request) {
|
||||
ranThing("Request2")
|
||||
},
|
||||
ghttp.RespondWithJSONEncoded(200, types.RemoteAfterSuiteData{false}),
|
||||
), ghttp.CombineHandlers(
|
||||
ghttp.VerifyRequest("GET", "/RemoteAfterSuiteData"),
|
||||
func(writer http.ResponseWriter, request *http.Request) {
|
||||
ranThing("Request3")
|
||||
},
|
||||
ghttp.RespondWithJSONEncoded(200, types.RemoteAfterSuiteData{true}),
|
||||
))
|
||||
|
||||
node = newNode(func() {
|
||||
ranThing("A")
|
||||
}, func() {
|
||||
ranThing("B")
|
||||
})
|
||||
|
||||
outcome = node.Run(1, 3, server.URL())
|
||||
})
|
||||
|
||||
It("should run A and, when the server says its time, run B", func() {
|
||||
Ω(thingsThatRan()).Should(Equal([]string{"A", "Request1", "Request2", "Request3", "B"}))
|
||||
})
|
||||
|
||||
It("should report success", func() {
|
||||
Ω(outcome).Should(BeTrue())
|
||||
Ω(node.Passed()).Should(BeTrue())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStatePassed))
|
||||
})
|
||||
})
|
||||
|
||||
Context("as any other node", func() {
|
||||
BeforeEach(func() {
|
||||
node = newNode(func() {
|
||||
ranThing("A")
|
||||
}, func() {
|
||||
ranThing("B")
|
||||
})
|
||||
|
||||
outcome = node.Run(2, 3, server.URL())
|
||||
})
|
||||
|
||||
It("should run A, and not run B", func() {
|
||||
Ω(thingsThatRan()).Should(Equal([]string{"A"}))
|
||||
})
|
||||
|
||||
It("should not talk to the server", func() {
|
||||
Ω(server.ReceivedRequests()).Should(BeEmpty())
|
||||
})
|
||||
|
||||
It("should report success", func() {
|
||||
Ω(outcome).Should(BeTrue())
|
||||
Ω(node.Passed()).Should(BeTrue())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStatePassed))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
445
vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_before_suite_node_test.go
generated
vendored
445
vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_before_suite_node_test.go
generated
vendored
@@ -1,445 +0,0 @@
|
||||
package leafnodes_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/internal/leafnodes"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/onsi/gomega/ghttp"
|
||||
"net/http"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
Failer "github.com/onsi/ginkgo/internal/failer"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
"time"
|
||||
)
|
||||
|
||||
var _ = Describe("SynchronizedBeforeSuiteNode", func() {
|
||||
var failer *Failer.Failer
|
||||
var node SuiteNode
|
||||
var codeLocation types.CodeLocation
|
||||
var innerCodeLocation types.CodeLocation
|
||||
var outcome bool
|
||||
var server *ghttp.Server
|
||||
|
||||
BeforeEach(func() {
|
||||
server = ghttp.NewServer()
|
||||
codeLocation = codelocation.New(0)
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
failer = Failer.New()
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
server.Close()
|
||||
})
|
||||
|
||||
newNode := func(bodyA interface{}, bodyB interface{}) SuiteNode {
|
||||
return NewSynchronizedBeforeSuiteNode(bodyA, bodyB, codeLocation, time.Millisecond, failer)
|
||||
}
|
||||
|
||||
Describe("when not running in parallel", func() {
|
||||
Context("when all is well", func() {
|
||||
var data []byte
|
||||
BeforeEach(func() {
|
||||
data = nil
|
||||
|
||||
node = newNode(func() []byte {
|
||||
return []byte("my data")
|
||||
}, func(d []byte) {
|
||||
data = d
|
||||
})
|
||||
|
||||
outcome = node.Run(1, 1, server.URL())
|
||||
})
|
||||
|
||||
It("should run A, then B passing the output from A to B", func() {
|
||||
Ω(data).Should(Equal([]byte("my data")))
|
||||
})
|
||||
|
||||
It("should report success", func() {
|
||||
Ω(outcome).Should(BeTrue())
|
||||
Ω(node.Passed()).Should(BeTrue())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStatePassed))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when A fails", func() {
|
||||
var ranB bool
|
||||
BeforeEach(func() {
|
||||
ranB = false
|
||||
node = newNode(func() []byte {
|
||||
failer.Fail("boom", innerCodeLocation)
|
||||
return nil
|
||||
}, func([]byte) {
|
||||
ranB = true
|
||||
})
|
||||
|
||||
outcome = node.Run(1, 1, server.URL())
|
||||
})
|
||||
|
||||
It("should not run B", func() {
|
||||
Ω(ranB).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should report failure", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(node.Passed()).Should(BeFalse())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStateFailed))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when B fails", func() {
|
||||
BeforeEach(func() {
|
||||
node = newNode(func() []byte {
|
||||
return nil
|
||||
}, func([]byte) {
|
||||
failer.Fail("boom", innerCodeLocation)
|
||||
})
|
||||
|
||||
outcome = node.Run(1, 1, server.URL())
|
||||
})
|
||||
|
||||
It("should report failure", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(node.Passed()).Should(BeFalse())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStateFailed))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when A times out", func() {
|
||||
var ranB bool
|
||||
BeforeEach(func() {
|
||||
ranB = false
|
||||
node = newNode(func(Done) []byte {
|
||||
time.Sleep(time.Second)
|
||||
return nil
|
||||
}, func([]byte) {
|
||||
ranB = true
|
||||
})
|
||||
|
||||
outcome = node.Run(1, 1, server.URL())
|
||||
})
|
||||
|
||||
It("should not run B", func() {
|
||||
Ω(ranB).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should report failure", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(node.Passed()).Should(BeFalse())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStateTimedOut))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when B times out", func() {
|
||||
BeforeEach(func() {
|
||||
node = newNode(func() []byte {
|
||||
return nil
|
||||
}, func([]byte, Done) {
|
||||
time.Sleep(time.Second)
|
||||
})
|
||||
|
||||
outcome = node.Run(1, 1, server.URL())
|
||||
})
|
||||
|
||||
It("should report failure", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(node.Passed()).Should(BeFalse())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStateTimedOut))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("when running in parallel", func() {
|
||||
var ranB bool
|
||||
var parallelNode, parallelTotal int
|
||||
BeforeEach(func() {
|
||||
ranB = false
|
||||
parallelNode, parallelTotal = 1, 3
|
||||
})
|
||||
|
||||
Context("as the first node, it runs A", func() {
|
||||
var expectedState types.RemoteBeforeSuiteData
|
||||
|
||||
BeforeEach(func() {
|
||||
parallelNode, parallelTotal = 1, 3
|
||||
})
|
||||
|
||||
JustBeforeEach(func() {
|
||||
server.AppendHandlers(ghttp.CombineHandlers(
|
||||
ghttp.VerifyRequest("POST", "/BeforeSuiteState"),
|
||||
ghttp.VerifyJSONRepresenting(expectedState),
|
||||
))
|
||||
|
||||
outcome = node.Run(parallelNode, parallelTotal, server.URL())
|
||||
})
|
||||
|
||||
Context("when A succeeds", func() {
|
||||
BeforeEach(func() {
|
||||
expectedState = types.RemoteBeforeSuiteData{[]byte("my data"), types.RemoteBeforeSuiteStatePassed}
|
||||
|
||||
node = newNode(func() []byte {
|
||||
return []byte("my data")
|
||||
}, func([]byte) {
|
||||
ranB = true
|
||||
})
|
||||
})
|
||||
|
||||
It("should post about A succeeding", func() {
|
||||
Ω(server.ReceivedRequests()).Should(HaveLen(1))
|
||||
})
|
||||
|
||||
It("should run B", func() {
|
||||
Ω(ranB).Should(BeTrue())
|
||||
})
|
||||
|
||||
It("should report success", func() {
|
||||
Ω(outcome).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when A fails", func() {
|
||||
BeforeEach(func() {
|
||||
expectedState = types.RemoteBeforeSuiteData{nil, types.RemoteBeforeSuiteStateFailed}
|
||||
|
||||
node = newNode(func() []byte {
|
||||
panic("BAM")
|
||||
return []byte("my data")
|
||||
}, func([]byte) {
|
||||
ranB = true
|
||||
})
|
||||
})
|
||||
|
||||
It("should post about A failing", func() {
|
||||
Ω(server.ReceivedRequests()).Should(HaveLen(1))
|
||||
})
|
||||
|
||||
It("should not run B", func() {
|
||||
Ω(ranB).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should report failure", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("as the Nth node", func() {
|
||||
var statusCode int
|
||||
var response interface{}
|
||||
var ranA bool
|
||||
var bData []byte
|
||||
|
||||
BeforeEach(func() {
|
||||
ranA = false
|
||||
bData = nil
|
||||
|
||||
statusCode = http.StatusOK
|
||||
|
||||
server.AppendHandlers(ghttp.CombineHandlers(
|
||||
ghttp.VerifyRequest("GET", "/BeforeSuiteState"),
|
||||
ghttp.RespondWith(http.StatusOK, string((types.RemoteBeforeSuiteData{nil, types.RemoteBeforeSuiteStatePending}).ToJSON())),
|
||||
), ghttp.CombineHandlers(
|
||||
ghttp.VerifyRequest("GET", "/BeforeSuiteState"),
|
||||
ghttp.RespondWith(http.StatusOK, string((types.RemoteBeforeSuiteData{nil, types.RemoteBeforeSuiteStatePending}).ToJSON())),
|
||||
), ghttp.CombineHandlers(
|
||||
ghttp.VerifyRequest("GET", "/BeforeSuiteState"),
|
||||
ghttp.RespondWithJSONEncodedPtr(&statusCode, &response),
|
||||
))
|
||||
|
||||
node = newNode(func() []byte {
|
||||
ranA = true
|
||||
return nil
|
||||
}, func(data []byte) {
|
||||
bData = data
|
||||
})
|
||||
|
||||
parallelNode, parallelTotal = 2, 3
|
||||
})
|
||||
|
||||
Context("when A on node1 succeeds", func() {
|
||||
BeforeEach(func() {
|
||||
response = types.RemoteBeforeSuiteData{[]byte("my data"), types.RemoteBeforeSuiteStatePassed}
|
||||
outcome = node.Run(parallelNode, parallelTotal, server.URL())
|
||||
})
|
||||
|
||||
It("should not run A", func() {
|
||||
Ω(ranA).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should poll for A", func() {
|
||||
Ω(server.ReceivedRequests()).Should(HaveLen(3))
|
||||
})
|
||||
|
||||
It("should run B when the polling succeeds", func() {
|
||||
Ω(bData).Should(Equal([]byte("my data")))
|
||||
})
|
||||
|
||||
It("should succeed", func() {
|
||||
Ω(outcome).Should(BeTrue())
|
||||
Ω(node.Passed()).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when A on node1 fails", func() {
|
||||
BeforeEach(func() {
|
||||
response = types.RemoteBeforeSuiteData{[]byte("my data"), types.RemoteBeforeSuiteStateFailed}
|
||||
outcome = node.Run(parallelNode, parallelTotal, server.URL())
|
||||
})
|
||||
|
||||
It("should not run A", func() {
|
||||
Ω(ranA).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should poll for A", func() {
|
||||
Ω(server.ReceivedRequests()).Should(HaveLen(3))
|
||||
})
|
||||
|
||||
It("should not run B", func() {
|
||||
Ω(bData).Should(BeNil())
|
||||
})
|
||||
|
||||
It("should fail", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(node.Passed()).Should(BeFalse())
|
||||
|
||||
summary := node.Summary()
|
||||
Ω(summary.State).Should(Equal(types.SpecStateFailed))
|
||||
Ω(summary.Failure.Message).Should(Equal("BeforeSuite on Node 1 failed"))
|
||||
Ω(summary.Failure.Location).Should(Equal(codeLocation))
|
||||
Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite))
|
||||
Ω(summary.Failure.ComponentIndex).Should(Equal(0))
|
||||
Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when node1 disappears", func() {
|
||||
BeforeEach(func() {
|
||||
response = types.RemoteBeforeSuiteData{[]byte("my data"), types.RemoteBeforeSuiteStateDisappeared}
|
||||
outcome = node.Run(parallelNode, parallelTotal, server.URL())
|
||||
})
|
||||
|
||||
It("should not run A", func() {
|
||||
Ω(ranA).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should poll for A", func() {
|
||||
Ω(server.ReceivedRequests()).Should(HaveLen(3))
|
||||
})
|
||||
|
||||
It("should not run B", func() {
|
||||
Ω(bData).Should(BeNil())
|
||||
})
|
||||
|
||||
It("should fail", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(node.Passed()).Should(BeFalse())
|
||||
|
||||
summary := node.Summary()
|
||||
Ω(summary.State).Should(Equal(types.SpecStateFailed))
|
||||
Ω(summary.Failure.Message).Should(Equal("Node 1 disappeared before completing BeforeSuite"))
|
||||
Ω(summary.Failure.Location).Should(Equal(codeLocation))
|
||||
Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite))
|
||||
Ω(summary.Failure.ComponentIndex).Should(Equal(0))
|
||||
Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("construction", func() {
|
||||
Describe("the first function", func() {
|
||||
Context("when the first function returns a byte array", func() {
|
||||
Context("and takes nothing", func() {
|
||||
It("should be fine", func() {
|
||||
Ω(func() {
|
||||
newNode(func() []byte { return nil }, func([]byte) {})
|
||||
}).ShouldNot(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Context("and takes a done function", func() {
|
||||
It("should be fine", func() {
|
||||
Ω(func() {
|
||||
newNode(func(Done) []byte { return nil }, func([]byte) {})
|
||||
}).ShouldNot(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Context("and takes more than one thing", func() {
|
||||
It("should panic", func() {
|
||||
Ω(func() {
|
||||
newNode(func(Done, Done) []byte { return nil }, func([]byte) {})
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Context("and takes something else", func() {
|
||||
It("should panic", func() {
|
||||
Ω(func() {
|
||||
newNode(func(bool) []byte { return nil }, func([]byte) {})
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the first function does not return a byte array", func() {
|
||||
It("should panic", func() {
|
||||
Ω(func() {
|
||||
newNode(func() {}, func([]byte) {})
|
||||
}).Should(Panic())
|
||||
|
||||
Ω(func() {
|
||||
newNode(func() []int { return nil }, func([]byte) {})
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("the second function", func() {
|
||||
Context("when the second function takes a byte array", func() {
|
||||
It("should be fine", func() {
|
||||
Ω(func() {
|
||||
newNode(func() []byte { return nil }, func([]byte) {})
|
||||
}).ShouldNot(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when it also takes a done channel", func() {
|
||||
It("should be fine", func() {
|
||||
Ω(func() {
|
||||
newNode(func() []byte { return nil }, func([]byte, Done) {})
|
||||
}).ShouldNot(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Context("if it takes anything else", func() {
|
||||
It("should panic", func() {
|
||||
Ω(func() {
|
||||
newNode(func() []byte { return nil }, func([]byte, chan bool) {})
|
||||
}).Should(Panic())
|
||||
|
||||
Ω(func() {
|
||||
newNode(func() []byte { return nil }, func(string) {})
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Context("if it takes nothing at all", func() {
|
||||
It("should panic", func() {
|
||||
Ω(func() {
|
||||
newNode(func() []byte { return nil }, func() {})
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Context("if it returns something", func() {
|
||||
It("should panic", func() {
|
||||
Ω(func() {
|
||||
newNode(func() []byte { return nil }, func([]byte) []byte { return nil })
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user