Changeset 5490
- Timestamp:
- Nov 8, 2005, 3:31:07 PM (21 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
Nebulous-Server/lib/Nebulous/Server.pm (modified) (3 diffs)
-
Nebulous-Server/lib/Nebulous/Server/SQL.pm (modified) (2 diffs)
-
Nebulous-Server/t/03_server_create_object.t (modified) (2 diffs)
-
Nebulous/lib/Nebulous/Server.pm (modified) (3 diffs)
-
Nebulous/lib/Nebulous/Server/SQL.pm (modified) (2 diffs)
-
Nebulous/t/03_server_create_object.t (modified) (2 diffs)
-
Nebulous/t/Test/Nebulous.pm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/lib/Nebulous/Server.pm
r5487 r5490 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1.1 2 2005-11-09 00:48:24jhoblitt Exp $3 # $Id: Server.pm,v 1.13 2005-11-09 01:31:07 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 17 17 use Log::Log4perl; 18 18 use Params::Validate qw( validate_pos SCALAR ); 19 20 my %class = (21 raw => 1,22 );23 19 24 20 my $log; … … 99 95 100 96 # check that the comment isn't too long 97 # check that the volume requested is valid 98 101 99 # check that the class requested is valid 102 # check that the volume requested is valid 100 if ( $class ) { 101 my $class_id; 102 eval { 103 my $query = $db->prepare_cached( $sql->get_class ); 104 $query->execute( $class ); 105 ( $class_id ) = $query->fetchrow_array; 106 107 $query->finish; 108 }; 109 if ( $@ ) { 110 $db->rollback; 111 $log->logdie( "database error: $@" ); 112 } 113 114 unless ( $class_id ) { 115 $log->logdie( "Invalid class ID: $class" ); 116 } 117 } 103 118 104 119 my $uri; -
trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm
r5489 r5490 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: SQL.pm,v 1.1 3 2005-11-09 00:59:20jhoblitt Exp $3 # $Id: SQL.pm,v 1.14 2005-11-09 01:31:07 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server::SQL; … … 123 123 INSERT INTO volume (name, uri) 124 124 VALUES (?, ?) 125 }, 126 get_class => qq{ 127 SELECT class_id, priority, comment 128 FROM class 129 WHERE class_id = ? 125 130 }, 126 131 ); -
trunk/Nebulous-Server/t/03_server_create_object.t
r4873 r5490 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 03_server_create_object.t,v 1. 5 2005-08-25 01:40:04jhoblitt Exp $5 # $Id: 03_server_create_object.t,v 1.6 2005-11-09 01:31:07 jhoblitt Exp $ 6 6 7 7 use strict; 8 8 use warnings FATAL => qw( all ); 9 9 10 use Test::More tests => 1 1;10 use Test::More tests => 13; 11 11 12 12 use lib qw( ./t ./lib ); … … 74 74 Test::Nebulous->setup; 75 75 76 { 77 my $uri = $neb->create_object( "foo", 1 ); 78 79 ok( -e _get_file_path( $uri ), "class exists" ); 80 } 81 82 Test::Nebulous->setup; 83 84 eval { 85 $neb->create_object( "foo", 99 ); 86 }; 87 like( $@, qr/Invalid class/, "class doesn't exists" ); 88 89 Test::Nebulous->setup; 90 76 91 eval { 77 92 $neb->create_object(); -
trunk/Nebulous/lib/Nebulous/Server.pm
r5487 r5490 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1.1 2 2005-11-09 00:48:24jhoblitt Exp $3 # $Id: Server.pm,v 1.13 2005-11-09 01:31:07 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 17 17 use Log::Log4perl; 18 18 use Params::Validate qw( validate_pos SCALAR ); 19 20 my %class = (21 raw => 1,22 );23 19 24 20 my $log; … … 99 95 100 96 # check that the comment isn't too long 97 # check that the volume requested is valid 98 101 99 # check that the class requested is valid 102 # check that the volume requested is valid 100 if ( $class ) { 101 my $class_id; 102 eval { 103 my $query = $db->prepare_cached( $sql->get_class ); 104 $query->execute( $class ); 105 ( $class_id ) = $query->fetchrow_array; 106 107 $query->finish; 108 }; 109 if ( $@ ) { 110 $db->rollback; 111 $log->logdie( "database error: $@" ); 112 } 113 114 unless ( $class_id ) { 115 $log->logdie( "Invalid class ID: $class" ); 116 } 117 } 103 118 104 119 my $uri; -
trunk/Nebulous/lib/Nebulous/Server/SQL.pm
r5489 r5490 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: SQL.pm,v 1.1 3 2005-11-09 00:59:20jhoblitt Exp $3 # $Id: SQL.pm,v 1.14 2005-11-09 01:31:07 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server::SQL; … … 123 123 INSERT INTO volume (name, uri) 124 124 VALUES (?, ?) 125 }, 126 get_class => qq{ 127 SELECT class_id, priority, comment 128 FROM class 129 WHERE class_id = ? 125 130 }, 126 131 ); -
trunk/Nebulous/t/03_server_create_object.t
r4873 r5490 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 03_server_create_object.t,v 1. 5 2005-08-25 01:40:04jhoblitt Exp $5 # $Id: 03_server_create_object.t,v 1.6 2005-11-09 01:31:07 jhoblitt Exp $ 6 6 7 7 use strict; 8 8 use warnings FATAL => qw( all ); 9 9 10 use Test::More tests => 1 1;10 use Test::More tests => 13; 11 11 12 12 use lib qw( ./t ./lib ); … … 74 74 Test::Nebulous->setup; 75 75 76 { 77 my $uri = $neb->create_object( "foo", 1 ); 78 79 ok( -e _get_file_path( $uri ), "class exists" ); 80 } 81 82 Test::Nebulous->setup; 83 84 eval { 85 $neb->create_object( "foo", 99 ); 86 }; 87 like( $@, qr/Invalid class/, "class doesn't exists" ); 88 89 Test::Nebulous->setup; 90 76 91 eval { 77 92 $neb->create_object(); -
trunk/Nebulous/t/Test/Nebulous.pm
r4893 r5490 1 1 # Copyright (C) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Nebulous.pm,v 1. 6 2005-08-27 03:39:06jhoblitt Exp $3 # $Id: Nebulous.pm,v 1.7 2005-11-09 01:31:07 jhoblitt Exp $ 4 4 5 5 package Test::Nebulous; … … 39 39 $dbh->do( qq{ INSERT INTO volume VALUES (1,'node01',?) }, undef, 'file:' . $dir1 ); 40 40 $dbh->do( qq{ INSERT INTO volume VALUES (2,'node02',?) }, undef, 'file:' . $dir2 ); 41 42 $dbh->do( qq{ INSERT INTO class VALUES (1, 0, "regular data") } ); 43 $dbh->do( qq{ INSERT INTO class VALUES (2, 1, "special data") } ); 41 44 } 42 45
Note:
See TracChangeset
for help on using the changeset viewer.
