test: Add benchmark Test for QueryNodes.toSQL()
Some checks are pending
Build / build (push) Waiting to run
Test / test (push) Waiting to run

This commit is contained in:
Christian Ditaputratama 2024-07-29 22:44:10 +07:00
parent 97fad6cacb
commit 4395a5e2d5
No known key found for this signature in database
GPG key ID: 31D3D06D77950979

View file

@ -35,6 +35,8 @@ func init() {
}
}
// Single test:
// go test -race ./internal/monero -run=TestQueryNodes_toSQL -v
func TestQueryNodes_toSQL(t *testing.T) {
tests := []struct {
name string
@ -102,6 +104,28 @@ func TestQueryNodes_toSQL(t *testing.T) {
}
}
// Single bench test:
// go test ./internal/monero -bench QueryNodes_toSQL -benchmem -run=^$ -v
func Benchmark_QueryNodes_toSQL(b *testing.B) {
for i := 0; i < b.N; i++ {
_, _, _, _ = QueryNodes{
Host: "test",
Nettype: "any",
Protocol: "any",
CC: "any",
Status: -1,
CORS: -1,
RowsPerPage: 10,
Page: 1,
SortBy: "last_checked",
SortDirection: "desc",
}.toSQL()
}
}
// equalArgs is helper function for testing.
//
// This returns true if two slices of interface{} are equal.
func equalArgs(a, b []interface{}) bool {
if len(a) != len(b) {
return false