@@ -32,6 +32,7 @@ import (
32
32
"time"
33
33
34
34
"github.com/questdb/go-questdb-client/v3"
35
+ qdb "github.com/questdb/go-questdb-client/v3"
35
36
"github.com/stretchr/testify/assert"
36
37
"github.com/stretchr/testify/require"
37
38
)
@@ -75,7 +76,35 @@ func TestBasicBehavior(t *testing.T) {
75
76
assert .Same (t , s3 , s5 )
76
77
}
77
78
78
- func TestDoubleReleaseShouldFail (t * testing.T ) {
79
+ func TestFlushOnClose (t * testing.T ) {
80
+ ctx := context .Background ()
81
+
82
+ srv , err := newTestHttpServer (readAndDiscard )
83
+ assert .NoError (t , err )
84
+ defer srv .Close ()
85
+
86
+ p , err := questdb .PoolFromOptions (
87
+ qdb .WithHttp (),
88
+ qdb .WithAddress (srv .Addr ()),
89
+ qdb .WithAutoFlushDisabled (),
90
+ )
91
+ assert .NoError (t , err )
92
+ defer p .Close (ctx )
93
+
94
+ s , err := p .Sender (ctx )
95
+ assert .NoError (t , err )
96
+
97
+ err = s .Table (testTable ).StringColumn ("bar" , "baz" ).AtNow (ctx )
98
+ assert .NoError (t , err )
99
+
100
+ assert .Equal (t , 1 , qdb .MsgCount (s ))
101
+
102
+ assert .NoError (t , s .Close (ctx ))
103
+
104
+ assert .Equal (t , 0 , qdb .MsgCount (s ))
105
+ }
106
+
107
+ func TestPooledSenderDoubleClose (t * testing.T ) {
79
108
p , err := questdb .PoolFromConf ("http::addr=localhost:1234" )
80
109
require .NoError (t , err )
81
110
0 commit comments