From c5975ba8b4816a8e462b0145a4fb6032c94978cb Mon Sep 17 00:00:00 2001 From: Adam Luzsi Date: Tue, 9 Feb 2021 00:03:01 +0100 Subject: [PATCH] change run conract api to use singular form instead of plural - finalize it --- Contract.go | 6 +++--- Contract_test.go | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Contract.go b/Contract.go index eed815a..5c9a332 100644 --- a/Contract.go +++ b/Contract.go @@ -22,7 +22,7 @@ type Contract interface { Benchmark(*testing.B) } -func RunContracts(tb interface{}, contracts ...Contract) { +func RunContract(tb interface{}, contracts ...Contract) { for _, c := range contracts { switch tb := tb.(type) { case *testing.T: @@ -32,11 +32,11 @@ func RunContracts(tb interface{}, contracts ...Contract) { c.Benchmark(tb) case *T: - RunContracts(tb.TB, c) + RunContract(tb.TB, c) case *Spec: c := c // copy to avoid reference overrides from "for" - tb.Test(fullyQualifiedName(c), func(t *T) { RunContracts(t, c) }) + tb.Test(fullyQualifiedName(c), func(t *T) { RunContract(t, c) }) default: panic(fmt.Errorf(`unknown test runner type: %T`, tb)) diff --git a/Contract_test.go b/Contract_test.go index 6d6c3bf..eeb3e1f 100644 --- a/Contract_test.go +++ b/Contract_test.go @@ -9,28 +9,28 @@ import ( func TestRunContracts(t *testing.T) { t.Run(`when TB is *testing.T`, func(t *testing.T) { sT := &RunContractExampleContract{} - testcase.RunContracts(&testing.T{}, sT) + testcase.RunContract(&testing.T{}, sT) require.True(t, sT.TestWasCalled) require.False(t, sT.BenchmarkWasCalled) }) t.Run(`when TB is *testing.B`, func(t *testing.T) { sB := &RunContractExampleContract{} - testcase.RunContracts(&testing.B{}, sB) + testcase.RunContract(&testing.B{}, sB) require.False(t, sB.TestWasCalled) require.True(t, sB.BenchmarkWasCalled) }) t.Run(`when TB is *testcase.T with *testing.T under the hood`, func(t *testing.T) { sT := &RunContractExampleContract{} - testcase.RunContracts(&testcase.T{TB: &testing.T{}}, sT) + testcase.RunContract(&testcase.T{TB: &testing.T{}}, sT) require.True(t, sT.TestWasCalled) require.False(t, sT.BenchmarkWasCalled) }) t.Run(`when TB is *testcase.T with *testing.B under the hood`, func(t *testing.T) { sT := &RunContractExampleContract{} - testcase.RunContracts(&testcase.T{TB: &testing.B{}}, sT) + testcase.RunContract(&testcase.T{TB: &testing.B{}}, sT) require.False(t, sT.TestWasCalled) require.True(t, sT.BenchmarkWasCalled) }) @@ -39,7 +39,7 @@ func TestRunContracts(t *testing.T) { s := testcase.NewSpec(t) a := &RunContractExampleContract{} b := &RunContractExampleContract{} - testcase.RunContracts(s, a, b) + testcase.RunContract(s, a, b) s.Finish() require.True(t, a.TestWasCalled) require.False(t, a.BenchmarkWasCalled)