@@ -10,10 +10,7 @@ import (
1010)
1111
1212func TestHTTPExceptionHandling (t * testing.T ) {
13- conn , err := clickhouse .Open (& clickhouse.Options {
14- Protocol : clickhouse .HTTP ,
15- Addr : []string {"localhost:8123" },
16- })
13+ conn , err := GetNativeConnection (t , clickhouse .HTTP , nil , nil , nil )
1714 require .NoError (t , err )
1815
1916 ctx := context .Background ()
@@ -49,43 +46,3 @@ func TestHTTPExceptionHandling(t *testing.T) {
4946
5047 assert .True (t , occured , "execption not caught in the response chunks" )
5148}
52-
53- func TestHTTPExceptionHandlingDB (t * testing.T ) {
54- conn := clickhouse .OpenDB (& clickhouse.Options {
55- Protocol : clickhouse .HTTP ,
56- Addr : []string {"localhost:8123" },
57- })
58-
59- ctx := context .Background ()
60-
61- // These settings will make sure mid-stream exception most likely on the server
62- ctx = clickhouse .Context (ctx , clickhouse .WithSettings (clickhouse.Settings {
63- "max_threads" : 1 ,
64- "max_block_size" : 1 ,
65- "http_write_exception_in_output_format" : 0 ,
66- "wait_end_of_query" : 0 ,
67- "http_response_buffer_size" : 1 ,
68- }))
69-
70- rows , err := conn .QueryContext (ctx , `SELECT throwIf(number=3, 'there is an exception') FROM system.numbers` )
71- require .NoError (t , err ) // query shouldn't fail with 500 status code.
72-
73- occured := false
74- // query should fail while scanning the rows mid-stream
75- for rows .Next () {
76- var result uint8
77- err := rows .Scan (& result )
78- if err != nil {
79- // should be an exception caught correctly
80- assert .Contains (t , err .Error (), "there is an exception" , "Expected exception message not caught" )
81- occured = true
82- }
83- }
84-
85- if err := rows .Err (); err != nil {
86- assert .Contains (t , err .Error (), "there is an exception" , "Expected exception message not caught" )
87- occured = true
88- }
89-
90- assert .True (t , occured , "execption not caught in the response chunks" )
91- }
0 commit comments