38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestBuildCandidateInsertMatchesBatchArguments(t *testing.T) {
|
|
query, args := buildCandidateInsert(temporaryTable, 10, 13, time.Now())
|
|
if strings.Count(query, "(?,?,?,?,?,?,?)") != 3 || strings.Count(query, "?") != len(args) || len(args) != 21 {
|
|
t.Fatalf("query/args mismatch: placeholders=%d args=%d query=%s", strings.Count(query, "?"), len(args), query)
|
|
}
|
|
}
|
|
|
|
func TestBenchmarkConfigRequiresExplicitDurableConfirmation(t *testing.T) {
|
|
valid := benchmarkConfig{Rows: 100_000, BatchSize: 500, Mode: durableMode, ConfirmDurable: true}
|
|
if err := valid.validate(); err != nil {
|
|
t.Fatalf("valid durable benchmark rejected: %v", err)
|
|
}
|
|
valid.ConfirmDurable = false
|
|
if err := valid.validate(); err == nil || !strings.Contains(err.Error(), "--confirm-durable-write") {
|
|
t.Fatalf("durable mode must require confirmation, got %v", err)
|
|
}
|
|
}
|
|
|
|
func TestBenchmarkConfigBoundsAndModes(t *testing.T) {
|
|
for _, config := range []benchmarkConfig{
|
|
{Rows: 0, BatchSize: 500, Mode: temporaryMode},
|
|
{Rows: 1, BatchSize: 1001, Mode: temporaryMode},
|
|
{Rows: 1, BatchSize: 1, Mode: "business-table"},
|
|
} {
|
|
if err := config.validate(); err == nil {
|
|
t.Fatalf("invalid config accepted: %+v", config)
|
|
}
|
|
}
|
|
}
|