Skip to content

Commit

Permalink
pkg/types/interfacetests: simplify test names (#959)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 authored Dec 4, 2024
1 parent 26d4a0b commit a946a57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
8 changes: 5 additions & 3 deletions pkg/types/interfacetests/chain_components_interface_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ var AnySliceToReadWithoutAnArgument = []uint64{3, 4}
const AnyExtraValue = 3

func RunContractReaderInterfaceTests[T TestingT[T]](t T, tester ChainComponentsInterfaceTester[T], mockRun bool) {
t.Run("GetLatestValue for "+tester.Name(), func(t T) { runContractReaderGetLatestValueInterfaceTests(t, tester, mockRun) })
t.Run("BatchGetLatestValues for "+tester.Name(), func(t T) { runContractReaderBatchGetLatestValuesInterfaceTests(t, tester, mockRun) })
t.Run("QueryKey for "+tester.Name(), func(t T) { runQueryKeyInterfaceTests(t, tester) })
t.Run(tester.Name(), func(t T) {
t.Run("GetLatestValue", func(t T) { runContractReaderGetLatestValueInterfaceTests(t, tester, mockRun) })
t.Run("BatchGetLatestValues", func(t T) { runContractReaderBatchGetLatestValuesInterfaceTests(t, tester, mockRun) })
t.Run("QueryKey", func(t T) { runQueryKeyInterfaceTests(t, tester) })
})
}

func runContractReaderGetLatestValueInterfaceTests[T TestingT[T]](t T, tester ChainComponentsInterfaceTester[T], mockRun bool) {
Expand Down
16 changes: 9 additions & 7 deletions pkg/types/interfacetests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ type TestingT[T any] interface {
// Tests execution utility function that will consider enabled / disabled test cases according to
// Basic Tester configuration.
func RunTests[T TestingT[T]](t T, tester BasicTester[T], tests []Testcase[T]) {
for _, test := range tests {
if !tester.IsDisabled(test.Name) {
t.Run(test.Name+" for "+tester.Name(), func(t T) {
tester.Setup(t)
test.Test(t)
})
t.Run(tester.Name(), func(t T) {
for _, test := range tests {
if !tester.IsDisabled(test.Name) {
t.Run(test.Name, func(t T) {
tester.Setup(t)
test.Test(t)
})
}
}
}
})
}

// Batch contract write takes a batch call entry and writes it to the chain using the ContractWriter.
Expand Down

0 comments on commit a946a57

Please sign in to comment.