@@ -506,6 +506,14 @@ def test_min_tickets
506
506
assert_equal ( 8 , resource . tickets )
507
507
end
508
508
509
+ def test_min_tickets_float
510
+ expected_warning = /semian min_tickets value 2\. 000000 is a float, converting to fixnum/
511
+ with_fake_std_error ( warn_message : expected_warning ) do
512
+ id = Time . now . strftime ( '%H:%M:%S.%N' )
513
+ Semian ::Resource . new ( id , quota : 0.49 , timeout : 0.1 , min_tickets : 2.0 )
514
+ end
515
+ end
516
+
509
517
def test_min_tickets_nil
510
518
id = Time . now . strftime ( '%H:%M:%S.%N' )
511
519
resource = Semian ::Resource . new ( id , quota : 0.49 , timeout : 0.1 , min_tickets : nil )
@@ -522,16 +530,9 @@ def test_min_tickets_nil
522
530
523
531
def test_min_tickets_zero
524
532
id = Time . now . strftime ( '%H:%M:%S.%N' )
525
- resource = Semian ::Resource . new ( id , quota : 0.49 , timeout : 0.1 , min_tickets : 0 )
526
- assert_equal ( 1 , resource . tickets )
527
- fork_workers ( resource : id , count : 1 , quota : 0.49 , min_tickets : 0 , timeout : 0.1 , wait_for_timeout : true )
528
- assert_equal ( 1 , resource . tickets )
529
- fork_workers ( resource : id , count : 1 , quota : 0.49 , min_tickets : 0 , timeout : 0.1 , wait_for_timeout : true )
530
- assert_equal ( 2 , resource . tickets )
531
- fork_workers ( resource : id , count : 1 , quota : 0.49 , min_tickets : 0 , timeout : 0.1 , wait_for_timeout : true )
532
- assert_equal ( 2 , resource . tickets )
533
- fork_workers ( resource : id , count : 12 , quota : 0.49 , min_tickets : 0 , timeout : 0.1 , wait_for_timeout : true )
534
- assert_equal ( 8 , resource . tickets )
533
+ assert_raises ArgumentError do
534
+ Semian ::Resource . new ( id , quota : 0.49 , timeout : 0.1 , min_tickets : 0 )
535
+ end
535
536
end
536
537
537
538
def test_min_tickets_negative
@@ -541,6 +542,13 @@ def test_min_tickets_negative
541
542
end
542
543
end
543
544
545
+ def test_min_tickets_out_of_range
546
+ id = Time . now . strftime ( '%H:%M:%S.%N' )
547
+ assert_raises ArgumentError do
548
+ Semian ::Resource . new ( id , quota : 0.49 , timeout : 0.1 , min_tickets : 32768 )
549
+ end
550
+ end
551
+
544
552
def create_resource ( *args )
545
553
@resources ||= [ ]
546
554
resource = Semian ::Resource . new ( *args )
0 commit comments