Skip to content

Commit

Permalink
feat: add MustPassRepeatedly internal integration test for config ove…
Browse files Browse the repository at this point in the history
…rride

Signed-off-by: maxcleme <maxime.clement@docker.com>
  • Loading branch information
maxcleme committed Aug 23, 2023
1 parent 42e46d9 commit 81926db
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions internal/internal_integration/config_must_pass_repeatedly_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package internal_integration_test

import (
"fmt"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/ginkgo/v2/internal/test_helpers"
. "github.com/onsi/gomega"
)

var _ = Describe("when config.MustPassRepeatedly is greater than 1", func() {
var success bool
JustBeforeEach(func() {
var counterB int
success, _ = RunFixture("flakey success", func() {
It("A", func() {})
It("B", func() {
counterB += 1
if counterB == 8 {
F(fmt.Sprintf("C - %d", counterB))
}
})
})
})

Context("when a test passes", func() {
BeforeEach(func() {
conf.MustPassRepeatedly = 5
})

It("reports that the suite passed", func() {
Ω(success).Should(BeTrue())
Ω(reporter.End).Should(BeASuiteSummary(NSpecs(2), NFailed(0), NPassed(2)))
})

It("reports that the test passed with the correct number of attempts", func() {
Ω(reporter.Did.Find("A")).Should(HavePassed(NumAttempts(5)))
Ω(reporter.Did.Find("B")).Should(HavePassed(NumAttempts(5)))
})
})

Context("when the test fails", func() {
BeforeEach(func() {
conf.MustPassRepeatedly = 10
})

It("reports that the suite failed", func() {
Ω(success).Should(BeFalse())
Ω(reporter.End).Should(BeASuiteSummary(NSpecs(2), NFailed(1), NPassed(1)))
})

It("reports that the test failed with the correct number of attempts", func() {
Ω(reporter.Did.Find("A")).Should(HavePassed(NumAttempts(10)))
Ω(reporter.Did.Find("B")).Should(HaveFailed(NumAttempts(8)))
})
})
})

0 comments on commit 81926db

Please sign in to comment.