Skip to content

Commit

Permalink
Merge pull request #253 from pohly/register-multiple-times
Browse files Browse the repository at this point in the history
sanity: support embedding tests multiple time in Ginkgo
  • Loading branch information
k8s-ci-robot authored Mar 19, 2020
2 parents 8f687ee + ddf8b3f commit db3c5ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/sanity/sanity.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ func Test(t GinkgoTestingT, config TestConfig) {
// GinkgoTest for use when the tests run. Therefore its content can
// still be modified in a BeforeEach. The sanity package itself treats
// it as read-only.
//
// Only tests defined with DescribeSanity after the last invocation with
// GinkgoTest (if there has be one) will be added, i.e. each test only
// gets added at most once.
func GinkgoTest(config *TestConfig) *TestContext {
sc := newTestContext(config)
registerTestsInGinkgo(sc)
Expand Down
4 changes: 4 additions & 0 deletions pkg/sanity/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,8 @@ func registerTestsInGinkgo(sc *TestContext) {
})
})
}
// Don't register tests more than once! More tests might
// be added later in a different context, followed by
// another registerTestsInGinkgo call.
tests = nil
}

0 comments on commit db3c5ce

Please sign in to comment.