Lines 220-229
subtest 'maxlength + enum' => sub {
Link Here
|
220 |
my $reversed_api_mapping = |
220 |
my $reversed_api_mapping = |
221 |
{ reverse map { defined $api_mapping->{$_} ? ( $_ => $api_mapping->{$_} ) : () } keys %$api_mapping }; |
221 |
{ reverse map { defined $api_mapping->{$_} ? ( $_ => $api_mapping->{$_} ) : () } keys %$api_mapping }; |
222 |
|
222 |
|
223 |
while ( my ( $attr, $properties ) = each %{ $definition->{properties} } ) { |
223 |
my $db_columns = $koha_object->_result->columns_info; |
224 |
my $db_col = $reversed_api_mapping->{$attr}; |
224 |
while ( my ( $db_col, $column_info ) = each %{$db_columns} ) { |
225 |
next unless $db_col; |
225 |
my $api_attr = $api_mapping->{$db_col} || $db_col; |
226 |
my $column_info = $koha_object->_result->column_info($db_col); |
226 |
my $properties = $definition->{properties}->{$api_attr}; |
|
|
227 |
|
228 |
next unless $properties; |
229 |
|
227 |
next unless $column_info->{size}; |
230 |
next unless $column_info->{size}; |
228 |
|
231 |
|
229 |
next if ref( $column_info->{size} ) eq 'ARRAY'; # decimal # FIXME Could have a test for this as well |
232 |
next if ref( $column_info->{size} ) eq 'ARRAY'; # decimal # FIXME Could have a test for this as well |
Lines 233-239
subtest 'maxlength + enum' => sub {
Link Here
|
233 |
; # FIXME This is not fully correct, we might want to make sure enum is set for both DB and spec. eg. now checkprevcheckout is enum only for the api spec |
236 |
; # FIXME This is not fully correct, we might want to make sure enum is set for both DB and spec. eg. now checkprevcheckout is enum only for the api spec |
234 |
|
237 |
|
235 |
if ( !exists $properties->{maxLength} || $column_info->{size} != $properties->{maxLength} ) { |
238 |
if ( !exists $properties->{maxLength} || $column_info->{size} != $properties->{maxLength} ) { |
236 |
push @failures, sprintf "%s.%s should have maxLength=%s in api spec", $def, $attr, $column_info->{size}; |
239 |
push @failures, sprintf "%s.%s should have maxLength=%s in api spec", $def, $api_attr, |
|
|
240 |
$column_info->{size}; |
237 |
} |
241 |
} |
238 |
} |
242 |
} |
239 |
is( scalar(@failures), 0, "maxLength tests for $def" ) or diag Dumper @failures; |
243 |
is( scalar(@failures), 0, "maxLength tests for $def" ) or diag Dumper @failures; |
240 |
- |
|
|