|
14 | 14 | expect( ObjectSpace.memsize_of(@conn) ).to be > DATA_OBJ_MEMSIZE
|
15 | 15 | end
|
16 | 16 |
|
| 17 | + describe "#inspect", :without_transaction do |
| 18 | + it "should print host, port and user of a fresh connection, but not more" do |
| 19 | + expect( @conn.inspect ).to match(/<PG::Connection:[0-9a-fx]+ host=localhost port=#{@port} user=\w*>/) |
| 20 | + end |
| 21 | + |
| 22 | + it "should tell about finished connection" do |
| 23 | + conn = PG.connect(@conninfo) |
| 24 | + conn.finish |
| 25 | + expect( conn.inspect ).to match(/<PG::Connection:[0-9a-fx]+ finished>/) |
| 26 | + end |
| 27 | + |
| 28 | + it "should tell about connection status" do |
| 29 | + conn = PG::Connection.connect_start(@conninfo) |
| 30 | + expect( conn.inspect ).to match(/ status=CONNECTION_STARTED/) |
| 31 | + end |
| 32 | + |
| 33 | + it "should tell about pipeline mode", :postgresql_14 do |
| 34 | + @conn.enter_pipeline_mode |
| 35 | + expect( @conn.inspect ).to match(/ pipeline_status=PQ_PIPELINE_ON/) |
| 36 | + end |
| 37 | + |
| 38 | + it "should tell about transaction_status" do |
| 39 | + @conn.send_query "select 8" |
| 40 | + expect( @conn.inspect ).to match(/ transaction_status=PQTRANS_ACTIVE/) |
| 41 | + end |
| 42 | + |
| 43 | + it "should tell about nonblocking mode" do |
| 44 | + @conn.setnonblocking true |
| 45 | + expect( @conn.inspect ).to match(/ nonblocking=true/) |
| 46 | + end |
| 47 | + |
| 48 | + it "should tell about non UTF8 client encoding" do |
| 49 | + @conn.set_client_encoding "ISO-8859-1" |
| 50 | + expect( @conn.inspect ).to match(/ client_encoding=LATIN1/) |
| 51 | + end |
| 52 | + |
| 53 | + it "should tell about non default type_map_for_results" do |
| 54 | + @conn.type_map_for_results = PG::TypeMapByColumn.new([]) |
| 55 | + expect( @conn.inspect ).to match(/ type_map_for_results=#<PG::TypeMapByColumn:[0-9a-fx]+>/) |
| 56 | + end |
| 57 | + |
| 58 | + it "should tell about non default type_map_for_queries" do |
| 59 | + @conn.type_map_for_queries = PG::TypeMapByColumn.new([]) |
| 60 | + expect( @conn.inspect ).to match(/ type_map_for_queries=#<PG::TypeMapByColumn:[0-9a-fx]+>/) |
| 61 | + end |
| 62 | + |
| 63 | + it "should tell about encoder_for_put_copy_data" do |
| 64 | + @conn.encoder_for_put_copy_data = PG::TextEncoder::CopyRow.new |
| 65 | + expect( @conn.inspect ).to match(/ encoder_for_put_copy_data=#<PG::TextEncoder::CopyRow:[0-9a-fx]+>/) |
| 66 | + end |
| 67 | + |
| 68 | + it "should tell about decoder_for_get_copy_data" do |
| 69 | + @conn.decoder_for_get_copy_data = PG::TextDecoder::CopyRow.new |
| 70 | + expect( @conn.inspect ).to match(/ decoder_for_get_copy_data=#<PG::TextDecoder::CopyRow:[0-9a-fx]+>/) |
| 71 | + end |
| 72 | + end |
| 73 | + |
17 | 74 | describe "PG::Connection#conninfo_parse" do
|
18 | 75 | it "encode and decode Hash to connection string to Hash" do
|
19 | 76 | hash = {
|
|
0 commit comments