MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestMatchPgStatActivityQuery

Function TestMatchPgStatActivityQuery

server/conn_test.go:3777–3818  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3775
3776 c.updateTxStatus("ROLLBACK")
3777
3778 if c.txStatus != txStatusIdle {
3779 t.Errorf("txStatus = %c, want %c", c.txStatus, txStatusIdle)
3780 }
3781 if len(c.cursors) != 0 {
3782 t.Errorf("expected 0 cursors after ROLLBACK, got %d", len(c.cursors))
3783 }
3784}
3785
3786func TestIsFetchForwardOnly(t *testing.T) {
3787 tests := []struct {
3788 name string
3789 dir pg_query.FetchDirection
3790 want bool
3791 }{
3792 {"undefined (default)", pg_query.FetchDirection_FETCH_DIRECTION_UNDEFINED, true},
3793 {"forward", pg_query.FetchDirection_FETCH_FORWARD, true},
3794 {"backward", pg_query.FetchDirection_FETCH_BACKWARD, false},
3795 {"absolute", pg_query.FetchDirection_FETCH_ABSOLUTE, false},
3796 {"relative", pg_query.FetchDirection_FETCH_RELATIVE, false},
3797 }
3798
3799 for _, tt := range tests {
3800 t.Run(tt.name, func(t *testing.T) {
3801 got := isFetchForwardOnly(tt.dir)
3802 if got != tt.want {
3803 t.Errorf("isFetchForwardOnly(%v) = %v, want %v", tt.dir, got, tt.want)
3804 }
3805 })
3806 }
3807}
3808
3809func TestCountDollarParams(t *testing.T) {
3810 tests := []struct {
3811 query string
3812 expected int
3813 }{
3814 {"SELECT 1", 0},
3815 {"SELECT $1", 1},
3816 {"SELECT $1, $2", 2},
3817 {"SELECT $2, $1", 2},
3818 {"SELECT $10", 10},
3819 {"INSERT INTO t VALUES ($1, $2, $3)", 3},
3820 {"SELECT * FROM t WHERE id = $1 AND name = $3", 3},
3821 {"", 0},

Callers

nothing calls this directly

Calls 2

matchPgStatActivityQueryFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected