mysqlbinlog/parse_options_test.go

58 lines
1.8 KiB
Go
Raw Permalink Normal View History

package binlog
import (
"context"
"encoding/json"
"errors"
"strings"
"testing"
)
func TestParseBinlogWithOptions_ProgressAndStop(t *testing.T) {
t.Skip("skips large-binlog integration test; this standalone module must not depend on external sample files")
}
func TestParseBinlogWithOptions_ContextCancel(t *testing.T) {
path := "./test/mysql-bin56.000003"
ctx, cancel := context.WithCancel(context.Background())
cancel()
err := ParseBinlogWithOptions(path, ParseOptions{Context: ctx}, func(Transaction) bool {
t.Fatal("transaction callback should not run after context cancellation")
return false
})
if !errors.Is(err, context.Canceled) {
t.Fatalf("expected context.Canceled, got %v", err)
}
}
func TestParseBinlogWithOptions_ParseBinSample(t *testing.T) {
t.Skip("skips large-binlog integration test; this standalone module must not depend on external sample files")
}
func TestParseBinlogWithOptions_LargeBinProgressStop(t *testing.T) {
t.Skip("skips large-binlog integration test; this standalone module must not depend on external sample files")
}
func TestParseBinlogWithOptions_ExcludeAllGTIDDoesNotEmitEmptyTransaction(t *testing.T) {
t.Skip("skips large-binlog integration test; this standalone module must not depend on external sample files")
}
func TestTransactionJSONPreservesZeroLogicalClockValues(t *testing.T) {
raw, err := json.Marshal(Transaction{
GTID: "uuid:1",
LastCommitted: 0,
SequenceNumber: 1,
})
if err != nil {
t.Fatalf("marshal transaction failed: %v", err)
}
doc := string(raw)
if !strings.Contains(doc, `"lastCommitted":0`) {
t.Fatalf("expected zero lastCommitted to be present, got %s", doc)
}
if !strings.Contains(doc, `"sequenceNumber":1`) {
t.Fatalf("expected sequenceNumber to be present, got %s", doc)
}
}