Skip to content

Commit

Permalink
Add replication handler tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eminano committed Jul 1, 2024
1 parent fd282fc commit 86cc73b
Show file tree
Hide file tree
Showing 2 changed files with 526 additions and 0 deletions.
45 changes: 45 additions & 0 deletions pkg/wal/replication/postgres/helper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: Apache-2.0

package postgres

import (
"errors"
"fmt"
"time"
)

type mockRow struct {
lsn string
lag int64
scanFn func(args ...any) error
}

func (m *mockRow) Scan(args ...any) error {
if m.scanFn != nil {
return m.scanFn(args...)
}

switch arg := args[0].(type) {
case *string:
*arg = m.lsn
case *int64:
*arg = m.lag
default:
return fmt.Errorf("unexpected argument type in scan: %T", args[0])
}

return nil
}

const (
testDBName = "test-db"
testSlot = "test_slot"
testLSN = uint64(7773397064)
testLSNStr = "1/CF54A048"
)

var (
errTest = errors.New("oh noes")

now = time.Now()
)
Loading

0 comments on commit 86cc73b

Please sign in to comment.