Retry temporary errors by default (#107)
* Adding Aurora URL validator in order to handle scenarios where incomplete information is passed to the client. The client will do its best to guess the missing information such as protocol and port. * Upgraded to testify 1.3.0. * Added configuration to fail on a non-temporary error. This is reverting to the original behavior of the retry mechanism. However, this allows the user to opt to fail in a non-temporary error.
This commit is contained in:
parent
4ffb509939
commit
6dc4bf93b9
37 changed files with 2795 additions and 1009 deletions
134
vendor/github.com/stretchr/testify/suite/suite_test.go
generated
vendored
134
vendor/github.com/stretchr/testify/suite/suite_test.go
generated
vendored
|
@ -42,6 +42,99 @@ func (s *SuiteRequireTwice) TestRequireTwo() {
|
|||
r.Equal(1, 2)
|
||||
}
|
||||
|
||||
type panickingSuite struct {
|
||||
Suite
|
||||
panicInSetupSuite bool
|
||||
panicInSetupTest bool
|
||||
panicInBeforeTest bool
|
||||
panicInTest bool
|
||||
panicInAfterTest bool
|
||||
panicInTearDownTest bool
|
||||
panicInTearDownSuite bool
|
||||
}
|
||||
|
||||
func (s *panickingSuite) SetupSuite() {
|
||||
if s.panicInSetupSuite {
|
||||
panic("oops in setup suite")
|
||||
}
|
||||
}
|
||||
|
||||
func (s *panickingSuite) SetupTest() {
|
||||
if s.panicInSetupTest {
|
||||
panic("oops in setup test")
|
||||
}
|
||||
}
|
||||
|
||||
func (s *panickingSuite) BeforeTest(_, _ string) {
|
||||
if s.panicInBeforeTest {
|
||||
panic("oops in before test")
|
||||
}
|
||||
}
|
||||
|
||||
func (s *panickingSuite) Test() {
|
||||
if s.panicInTest {
|
||||
panic("oops in test")
|
||||
}
|
||||
}
|
||||
|
||||
func (s *panickingSuite) AfterTest(_, _ string) {
|
||||
if s.panicInAfterTest {
|
||||
panic("oops in after test")
|
||||
}
|
||||
}
|
||||
|
||||
func (s *panickingSuite) TearDownTest() {
|
||||
if s.panicInTearDownTest {
|
||||
panic("oops in tear down test")
|
||||
}
|
||||
}
|
||||
|
||||
func (s *panickingSuite) TearDownSuite() {
|
||||
if s.panicInTearDownSuite {
|
||||
panic("oops in tear down suite")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSuiteRecoverPanic(t *testing.T) {
|
||||
ok := true
|
||||
panickingTests := []testing.InternalTest{
|
||||
{
|
||||
Name: "TestPanicInSetupSuite",
|
||||
F: func(t *testing.T) { Run(t, &panickingSuite{panicInSetupSuite: true}) },
|
||||
},
|
||||
{
|
||||
Name: "TestPanicInSetupTest",
|
||||
F: func(t *testing.T) { Run(t, &panickingSuite{panicInSetupTest: true}) },
|
||||
},
|
||||
{
|
||||
Name: "TestPanicInBeforeTest",
|
||||
F: func(t *testing.T) { Run(t, &panickingSuite{panicInBeforeTest: true}) },
|
||||
},
|
||||
{
|
||||
Name: "TestPanicInTest",
|
||||
F: func(t *testing.T) { Run(t, &panickingSuite{panicInTest: true}) },
|
||||
},
|
||||
{
|
||||
Name: "TestPanicInAfterTest",
|
||||
F: func(t *testing.T) { Run(t, &panickingSuite{panicInAfterTest: true}) },
|
||||
},
|
||||
{
|
||||
Name: "TestPanicInTearDownTest",
|
||||
F: func(t *testing.T) { Run(t, &panickingSuite{panicInTearDownTest: true}) },
|
||||
},
|
||||
{
|
||||
Name: "TestPanicInTearDownSuite",
|
||||
F: func(t *testing.T) { Run(t, &panickingSuite{panicInTearDownSuite: true}) },
|
||||
},
|
||||
}
|
||||
|
||||
require.NotPanics(t, func() {
|
||||
ok = testing.RunTests(allTestsFilter, panickingTests)
|
||||
})
|
||||
|
||||
assert.False(t, ok)
|
||||
}
|
||||
|
||||
// This suite is intended to store values to make sure that only
|
||||
// testing-suite-related methods are run. It's also a fully
|
||||
// functional example of a testing suite, using setup/teardown methods
|
||||
|
@ -59,6 +152,7 @@ type SuiteTester struct {
|
|||
TearDownTestRunCount int
|
||||
TestOneRunCount int
|
||||
TestTwoRunCount int
|
||||
TestSubtestRunCount int
|
||||
NonTestMethodRunCount int
|
||||
|
||||
SuiteNameBefore []string
|
||||
|
@ -153,6 +247,27 @@ func (suite *SuiteTester) NonTestMethod() {
|
|||
suite.NonTestMethodRunCount++
|
||||
}
|
||||
|
||||
func (suite *SuiteTester) TestSubtest() {
|
||||
suite.TestSubtestRunCount++
|
||||
|
||||
for _, t := range []struct {
|
||||
testName string
|
||||
}{
|
||||
{"first"},
|
||||
{"second"},
|
||||
} {
|
||||
suiteT := suite.T()
|
||||
suite.Run(t.testName, func() {
|
||||
// We should get a different *testing.T for subtests, so that
|
||||
// go test recognizes them as proper subtests for output formatting
|
||||
// and running individual subtests
|
||||
subTestT := suite.T()
|
||||
suite.NotEqual(subTestT, suiteT)
|
||||
})
|
||||
suite.Equal(suiteT, suite.T())
|
||||
}
|
||||
}
|
||||
|
||||
// TestRunSuite will be run by the 'go test' command, so within it, we
|
||||
// can run our suite using the Run(*testing.T, TestingSuite) function.
|
||||
func TestRunSuite(t *testing.T) {
|
||||
|
@ -168,18 +283,20 @@ func TestRunSuite(t *testing.T) {
|
|||
assert.Equal(t, suiteTester.SetupSuiteRunCount, 1)
|
||||
assert.Equal(t, suiteTester.TearDownSuiteRunCount, 1)
|
||||
|
||||
assert.Equal(t, len(suiteTester.SuiteNameAfter), 3)
|
||||
assert.Equal(t, len(suiteTester.SuiteNameBefore), 3)
|
||||
assert.Equal(t, len(suiteTester.TestNameAfter), 3)
|
||||
assert.Equal(t, len(suiteTester.TestNameBefore), 3)
|
||||
assert.Equal(t, len(suiteTester.SuiteNameAfter), 4)
|
||||
assert.Equal(t, len(suiteTester.SuiteNameBefore), 4)
|
||||
assert.Equal(t, len(suiteTester.TestNameAfter), 4)
|
||||
assert.Equal(t, len(suiteTester.TestNameBefore), 4)
|
||||
|
||||
assert.Contains(t, suiteTester.TestNameAfter, "TestOne")
|
||||
assert.Contains(t, suiteTester.TestNameAfter, "TestTwo")
|
||||
assert.Contains(t, suiteTester.TestNameAfter, "TestSkip")
|
||||
assert.Contains(t, suiteTester.TestNameAfter, "TestSubtest")
|
||||
|
||||
assert.Contains(t, suiteTester.TestNameBefore, "TestOne")
|
||||
assert.Contains(t, suiteTester.TestNameBefore, "TestTwo")
|
||||
assert.Contains(t, suiteTester.TestNameBefore, "TestSkip")
|
||||
assert.Contains(t, suiteTester.TestNameBefore, "TestSubtest")
|
||||
|
||||
for _, suiteName := range suiteTester.SuiteNameAfter {
|
||||
assert.Equal(t, "SuiteTester", suiteName)
|
||||
|
@ -197,15 +314,16 @@ func TestRunSuite(t *testing.T) {
|
|||
assert.False(t, when.IsZero())
|
||||
}
|
||||
|
||||
// There are three test methods (TestOne, TestTwo, and TestSkip), so
|
||||
// There are four test methods (TestOne, TestTwo, TestSkip, and TestSubtest), so
|
||||
// the SetupTest and TearDownTest methods (which should be run once for
|
||||
// each test) should have been run three times.
|
||||
assert.Equal(t, suiteTester.SetupTestRunCount, 3)
|
||||
assert.Equal(t, suiteTester.TearDownTestRunCount, 3)
|
||||
// each test) should have been run four times.
|
||||
assert.Equal(t, suiteTester.SetupTestRunCount, 4)
|
||||
assert.Equal(t, suiteTester.TearDownTestRunCount, 4)
|
||||
|
||||
// Each test should have been run once.
|
||||
assert.Equal(t, suiteTester.TestOneRunCount, 1)
|
||||
assert.Equal(t, suiteTester.TestTwoRunCount, 1)
|
||||
assert.Equal(t, suiteTester.TestSubtestRunCount, 1)
|
||||
|
||||
// Methods that don't match the test method identifier shouldn't
|
||||
// have been run at all.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue