Mercurial > hg > monetdb-perl
comparison MonetDB-CLI-MapiPP/MonetDB/CLI/t/02cxn.t @ 0:cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
author | Sjoerd Mullender <sjoerd@acm.org> |
---|---|
date | Mon, 19 Sep 2016 15:15:52 +0200 (2016-09-19) |
parents | |
children | a0ec9e080a5b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:cedccb7e0143 |
---|---|
1 # This Source Code Form is subject to the terms of the Mozilla Public | |
2 # License, v. 2.0. If a copy of the MPL was not distributed with this | |
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
4 # | |
5 # Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V. | |
6 | |
7 $| = 1; | |
8 | |
9 use strict; | |
10 use warnings; | |
11 | |
12 use Test::More tests => 18; | |
13 | |
14 use MonetDB::CLI::MapiPP; | |
15 | |
16 pass('Connection tests'); | |
17 | |
18 my $host = $ENV{MONETDB_HOST} || 'localhost'; | |
19 my $port = $ENV{MONETDB_PORT} || 50000; | |
20 my $user = $ENV{MONETDB_USER} || 'monetdb'; | |
21 my $pass = $ENV{MONETDB_PASS} || 'monetdb'; | |
22 my $lang = 'sql'; | |
23 | |
24 my $cxn = eval { | |
25 MonetDB::CLI::MapiPP->connect( $host, $port, $user, $pass, $lang ) | |
26 }; | |
27 ok(!$@,'connect') or print "# $@"; | |
28 ok( $cxn,"Connection object: $cxn"); | |
29 | |
30 my $req = eval { $cxn->query('select * from env() env') }; | |
31 ok(!$@,'query') or print "# $@"; | |
32 ok( $req,"Request object: $req"); | |
33 | |
34 my $cnt = eval { $req->columncount }; | |
35 is( $cnt, 2,"columncount: $cnt"); | |
36 | |
37 my $querytype = eval { $req->querytype }; | |
38 is( $querytype, 1,"querytype: $querytype"); | |
39 | |
40 for my $k ('id','rows_affected') { | |
41 my $v = eval { $req->$k }; | |
42 ok( defined $v,"$k: $v"); | |
43 } | |
44 for my $k ('name','type','length') { | |
45 for my $i ( 0, 1 ) { | |
46 my $v = eval { $req->$k( $i ) }; | |
47 ok( $v,"$k( $i ): $v"); | |
48 } | |
49 } | |
50 my $rows = 0; | |
51 while ( my $cnt = eval { $req->fetch } ) { | |
52 print '#'; | |
53 print "\t", $req->field( $_ ) for 0 .. $cnt-1; | |
54 print "\n"; | |
55 $rows++; | |
56 } | |
57 is( $rows, $req->rows_affected,"rows: $rows"); | |
58 | |
59 { | |
60 my $req = eval { $cxn->query('select * from non_existent_table') }; | |
61 ok( $@,"Error expected: $@"); | |
62 ok(!$req,'No request object'); | |
63 } |