(t *testing.T)
| 3635 | } |
| 3636 | |
| 3637 | func TestCursorCloseAllCursors(t *testing.T) { |
| 3638 | c := &clientConn{ |
| 3639 | cursors: map[string]*cursorState{ |
| 3640 | "cur1": {query: "SELECT 1"}, |
| 3641 | "cur2": {query: "SELECT 2"}, |
| 3642 | "cur3": {query: "SELECT 3"}, |
| 3643 | }, |
| 3644 | } |
| 3645 | |
| 3646 | if len(c.cursors) != 3 { |
| 3647 | t.Fatalf("expected 3 cursors, got %d", len(c.cursors)) |
| 3648 | } |
| 3649 | |
| 3650 | c.closeAllCursors() |
| 3651 | |
| 3652 | if len(c.cursors) != 0 { |
| 3653 | t.Errorf("after closeAllCursors, expected 0 cursors, got %d", len(c.cursors)) |
| 3654 | } |
| 3655 | } |
| 3656 | |
| 3657 | func TestCursorCloseSingle(t *testing.T) { |
| 3658 | c := &clientConn{ |
| 3659 | cursors: map[string]*cursorState{ |
| 3660 | "cur1": {query: "SELECT 1"}, |
| 3661 | "cur2": {query: "SELECT 2"}, |
| 3662 | }, |
| 3663 | } |
| 3664 | |
| 3665 | c.closeCursor("cur1") |
| 3666 | |
| 3667 | if len(c.cursors) != 1 { |
| 3668 | t.Errorf("expected 1 cursor remaining, got %d", len(c.cursors)) |
| 3669 | } |
| 3670 | if _, ok := c.cursors["cur2"]; !ok { |
| 3671 | t.Error("expected cur2 to still exist") |
| 3672 | } |
nothing calls this directly
no test coverage detected